Hi Everyone, I have an interesting problem where I’ve parented some gameObjects with 2D Collider components to my player that is being moved with a script. As the player object moves the colliders from the child objects are left behind despite the child objects themselves clearly being moved. So that said I’m not sure what I’ve done incorrectly to get colliders and child objects to move together.
Do those child objects have Rigidbody2D’s themselves? Rigidbody2D children of Rigidbody2D’s seem to have some strange behavior along those lines sometimes; I would avoid it if possible.
I just had this problem a few minutes ago. Try removing the Rigidbody2D from the child object. The collision and trigger events for the child are still called (for me) if the parent has a rigidbody attached.
Not sure what the strange behavior is you mention however a child rigid-body is not connected to a parent rigid-body in any way, unless the child is kinematic in which case it updates to follow the parent.
Colliders always attach to a rigid-body either on the same GO or if that isn’t available then it connects to the next rigid-body up through the parent hierarchy. This is what determines if a collider is to be static or not i.e. if there is no rigid-body to attach to, it’s static meaning it should not be moved for performance reasons.
If you remove the rigid-body from the child then any colliders at that GO or children GO will connect to a parent GO. Likewise, if you add a rigid-body, any colliders on that GO or children will connect to it, assuming they don’t already connect to their own.
Parented dynamic rigid-bodies have independent and unconnected dynamic behavior as far as the physics system is concerned. Sure, you can drag them around in the editor and they stay together but that’s the transform hierarchy, not the physics system.
Hope this helps a little.