hi I’m new to unity and I’m building an ios game in C#. all I would like to do is toggle a game object tag with touch input. I’m using a raycast (I got the script form another thread). I managed to get it working with a send message but have since found out that they are a bad habit to get in to. I have tried this but now touch inputs do nothing what so ever. I would really appreciate any advice or solutions. Is there an easier way to do this? Have I miss understood the whole situation? Thanks in advance.
void Update () {
TapSelect();
}
void TapSelect() {
foreach (Touch touch in Input.touches) {
if (touch.phase == TouchPhase.Began) {
Ray ray = Camera.main.ScreenPointToRay(touch.position);
RaycastHit hit ;
if (Physics.Raycast (ray, out hit)) {
if(hit.collider.tag == "objectOff")
{
hit.collider.tag = "objectOn";
}
else {
hit.collider.tag = "objectOff";
}
}
}
}
}
}