- Home /
Rigidbody inertia recalculation after detaching child colliders ?
Hi,
if I have an object which is a rigid body and contains a sphere collider and has 2 children. The children are no rigid bodies but both contain a box collider. I hope this is a valid way to combine multiple colliders reffering to one rigid body.
Now I want to detach a child(the collider). My question is: Is it enough to simply call childObject.transform.parent = null ? Which kind of impact does this have on my rigid body ? Does it know about the change ? Or does it still think that there is collider.
I guess that the rigid body does not recalculate the inertia which is necessary after changing the collider set.
Soo... are there better solutions or are there methods like "recalcInertia" ?
Regards, Chris
$$anonymous$$aybe it works when I delete the rigid body component after detaching a child and then add a new rb component...
Answer by -brainer- · Sep 17, 2013 at 04:27 AM
I have now examined the effects of detaching a gameobject from its parents via debugging and retrospection. After the call to
gameobject.transform.parent = null;
the rigidbody of this gameobject will be reset automatically. First the mass to 1.0f, then other rather meaningful values for inertia and center of mass. Administrative values like constraints stay. So don't forget to finish your rigidbody setup after detaching from the parent. Another interesting behavior happens with its parent. Mass of rigidbody does not change. Although inertia and center of mass automatically do. In my setup I used objects with colliders or a hierarchy of colliders respectively. (Unity 4.2).
Answer by sebas77 · Jan 31, 2014 at 03:12 PM
Unity3d does recompute all the rigidbody parameters on reparenting.
Your answer
Follow this Question
Related Questions
Translate.transform problems (collision/Rigibody) 0 Answers
3rd Person Physics not working? 1 Answer
Ignore Collision Temporarily 1 Answer
How to properly move a rigidbody/collider? 2 Answers
ignorecollision return error 0 Answers