hit.gameObject.tag throws error.

Right, I have a script that does various things depending on what the collider hits. To check that the collider hit the right object before it does anything i’m using:

if(hit.gameObject.tag == “donkey”)
{
}

It all works 100% when it hits the object with that tag but if it hits an object with a different tag it throws off this error: UnityException: GameObject has undefined tag!

Any help would be much appreciated!

It seems like he’s using OnControllerColliderHit(hit : ControllerColliderHit). But either way you change it to if(hit.gameObject.tag == (“donkey”)) after that it should work just fine

Just ran into this problem. This seems to have worked:

	else if( Other.gameObject.tag == "Untagged" )
	{
		// Debug.Log("Hit an object with an undefined tag");
	}