Hi, I’m trying to make a 2D game in Unity 5 and can’t seem to get the touch to work on my Android. I am rewriting my code to work with more than one finger so I had to drop the mouse simulation I had going on. Anyways, the code in question looks as follows:
public bool IsPressed()
{
if (Input.touchCount > 0)
{
for (int i = 0; i < Input.touchCount; i++)
{
Vector3 pos = Camera.main.ScreenToWorldPoint(Input.GetTouch(i).position);
if (GetComponent<BoxCollider2D>().OverlapPoint(Camera.main.ScreenToWorldPoint(pos)))
{
Debug.Log("Square was pressed!");
return true;
}
}
}
return false;
}
I’ve spent an entire day trying to debug and have tried many things trying to get it to work. I will be very very thankful for your help!