Hi,
Im using this code on a simple slider as per the help tutorial here - http://www.binpress.com/tutorial/unity3d-touch-input/133
However, there is a problem with the line:
if (Physics.Raycast(screenRay, out hit))
It doesnt seem to be recognising this condition. If I move the print statement above the if statement, it prints just fine, so Im sure its got to do with this line.
Any ideas what might be wrong?
if(nbTouches > 0)
{
for (int i = 0; i < nbTouches; i++)
{
Touch touch = Input.GetTouch(i);
if(touch.phase == TouchPhase.Began)
{
Ray screenRay = Camera.main.ScreenPointToRay(touch.position);
RaycastHit hit;
if (Physics.Raycast(screenRay, out hit))
{
print("User tapped on game object " + hit.collider.gameObject.name);
//handleTap(hit.collider.gameObject);
}
}
}
}