Getting object tag via raycast

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!");

I figured it out, i had to tag the children of the game object even though the game object was appropriately tagged, so my code worked fine.


Why dont you put a collider(say box collider) on the object mover with a height and make it as a trigger… If an object triggers the collider you can easily find that…