Can't Return the Tag of a Child Object

I am trying to get the tag of a child object on my player through OnCollisionEnter. But it actually returns the tag of the parent object, even though there is a separate collider and tag. How do I get around this? Or is this a problem with Unity itself? I have noticed some irregularities with Unity 5 lately. Thanks!

The code I am using is plain and simple: print (col.gameObject.tag);

Hello friend. You need the following code to get the tag of the child.


Hope this helps.

All you’re doing is printing the tag of the object triggering the collision in the code you’ve quoted - does the parent have a collider that is triggering the code? In the case you’ve quoted, however, you could just use col.transform.child.tag (pseudo code - I’m not in front of Unity to test it.)

I don’t know what it was but it seems to be working now… It seems like there is some very funky stuff happening in Unity soo… yeah.

I just found the solution,

instead of using col.gameObject.tag

try using col.collider.gameObject.transform.tag