- Home /
Unity Collision Returns child instead of parent object
I have a building object, with separate meshes under it as children as such ---> Building(Parent) - |---main structure - |---roof - |---window - |---base The main structure object has a box collider on it. Now, when I detect collision and try to output Debug.Log(col.gameObject.name) (col being a Collision instance), it gives me the name of the the main structure gameObject instead of the parent building object. I believe this is not what generally happens with Unity Collision. Does someone have any idea what is happening?
Answer by kalibcrone · Jul 23, 2017 at 05:55 PM
When dealing with collisions with objects containing children, the first sub-object (if not the parent itself) with a collider that contains a NON kinematic rigidbody will be the object that returns the collision.
Answer by koennieboy123 · Jul 23, 2017 at 05:30 PM
No, you will always get the name of the child. Only when a rigidbody is attached to the parent, then you will get the name of the parent.