Quantcast
Channel: Questions in topic: "gameobject.tag"
Viewing all articles
Browse latest Browse all 95

Getting object tag via raycast

$
0
0
So i have an object tagged as "Mover", and i want other game objects to know if they are over a mover or not, i've tried a few things but i'm a bit lost. Basically the object recognizes it's over something and will print the first debug.log, but it won't recognize the tag, so it's not printing the second debug.log. void Update () { RaycastHit hit = new RaycastHit (); if (Physics.Raycast(transform.position, Vector3.forward, out hit , castRange)) { Debug.Log ("I am on something..."); if (hit.collider.gameObject.tag == "Mover") { Debug.Log ("Oh, I am on a Mover!"); }

Viewing all articles
Browse latest Browse all 95

Trending Articles