- Home /
Strange transform hierarchy problem when adding a rigidbody into the hierarchy
Ok, in trying to improve performance discussed elsewhere i've started changing an existing model hierarchy with some dynamic and static physics meshes, into the same hierarchy but adding a rigidbody to the dynamic part.
To work around asset import problems I am adding a set of sensors into this hierarchy at runtime within start(). These objects are added underneath the dynamic object.
Now performance is improving a lot but i've noticed my game is broken because something strange is now happening with these sensor triggers that are inserted into the hierarchy.
The editor is showing them moving in sync with the rest of the object, but my debug information is showing that the actual colliders themselves are NOT moving. Another object is matching the motion of the dynamic object and yet in the debug info i can see it moving between the sensors when the editor is showing it sat on just the one sensor.
If i remove the rigidbody and go back to just using transform rotation then all works ok.
It's almost as if the transform hierarchy is getting something confused in the physics when creating a hierarchy like this
- Object
- Dynamic Parent (rigidbody, mesh collider)
- sensor array
- sensor1 (sphere collider trigger)
- sensor2 (sphere collider trigger)
- sensor3 (sphere collider trigger)
- sensor4 (sphere collider trigger)
- sensor array
- Static objects (mesh collider)
- Dynamic Parent (rigidbody, mesh collider)
with a rigidbody the sensors look like they're moving properly in the editor, but my debugging shows they're not.
without a rigidbody and just rotating the dynamic parent with its transform and in the editor everything looks the same, but the sensors this time are correctly rotating.
Has anyone got any idea what's going on?
Answer by Ben B · Nov 17, 2010 at 06:18 PM
It is a bug.
Here's a workaround: Fix for broken collider when parenting to rigidbody
Answer by Ben B · Nov 16, 2010 at 01:15 AM
Reproducible.
I couldn't have worded it better myself.
The child SphereColliders appear to move in the editor, but their actual location, as per Debug & TriggerEnter & Exit, is unaffected by the movement of the parent rigidBody.
This appears to be a bug.
Time to discuss workarounds? Appears in Unity3?
http://forum.unity3d.com/threads/25353-MovePosition-in-parent-child-relations-of-rigidbodies