if (Input.touchCount > 0) // If the any touch on the screen
{
Touch touch = Input.GetTouch(0); //First touch
// ray cast from camera to the sprite
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(touch.position), Vector2.zero);
// and if any sprite there and it has tag that we want......
if(hit.collider.tag == "Tag")
{
// Do something
}
}
}
{
Touch touch = Input.GetTouch(0); //First touch
// ray cast from camera to the sprite
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(touch.position), Vector2.zero);
// and if any sprite there and it has tag that we want......
if(hit.collider.tag == "Tag")
{
// Do something
}
}
}
No comments:
Post a Comment