Here is my code. PROBLEM IS IN COMMENTS IN CODE
void Update () {
int i = 0;
while (i < Input.touchCount) {
if (Input.GetTouch(i).phase == TouchPhase.Began) {
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
Debug.Log("TAP !");
// TILL HERE IT WORKS
if (Physics.Raycast(ray, out hit, Mathf.Infinity))
{
// BUT IT DOES NOT PRINT OUT HIT AND MORE
Debug.Log("HIT !");
if(hit.transform.name=="Bomb")
{
Debug.Log("HIT BOMB!");
}
}
}
++i;
}
}
↧