I’ve tried several variations of using Input.touches but it seems that no matter what, it is frustratingly missing some of the touch events which is leading to players having to double or even triple touch sometimes on their android screen just to get the event to fire.
Does anyone see a problem with this code?
void Update()
{
if(Input.touchCount > 0)
{
foreach(Touch touch in Input.touches)
{
if(touch.phase == TouchPhase.Began)
{
Ray ray = gameManager.mainCamera.ScreenPointToRay(touch.position);
RaycastHit2D hit = Physics2D.Raycast (ray.origin, ray.direction, Mathf.Infinity);
if (hit) {
if(hit.transform.tag == "PlayerCore")
{
//functions and stuff here that are not always firing....
}
}
}
}
}
}