Hi, I am trying to detect the tag of a gameObject when it collides with another object. Here is my script so far:
function OnCollisionEnter (collision:Collision)
{
if (collision.gameObject.tag == "MyTag")
{
Debug.Log("MyTag");
}
else if (collision.gameObject.tag == "MyOtherTag")
{
Debug.Log("MyOtherTag");
}
}
It compiles and everything, but when I collide with an object with one of those tags I don’t get anything added to the log. Am I missing something or is this just not possible? Thanks in advance for any help!
PS: I got it to work using gameObject.name, but I would much rather use tags instead of names. Thanks again!
EDIT: Hmmm… It seems to work with OnTriggerEnter(other:Collider), but I would still like to know if this can be done with OnCollisionEnter()?