- Home /
Rigidbody and Parenting - Kinematic Rigidbodies?
The manual mentions that "you should never have a parent and child rigidbody together"
http://unity3d.com/support/documentation/Manual/Physics.html
Why is this?
Does this apply to a kinematic rigidbody?
Answer by Bunny83 · Dec 28, 2011 at 01:59 AM
If you read the page you've linked carefully you can read this ("Parenting"):
When an object is under physics control, it moves semi-independently of the way its transform parents move. If you move any parents, they will pull the Rigidbody child along with them. However, the Rigidbodies will still fall down due to gravity and react to collision events.
This applies only to normal Rigidbodies. Kinematic RBs aren't affected by any external forces.
What if you have a combination of both regular RB's and kinematic RB's in one hierarchy?
Ok, once and for all: Do not parent regular (non kinematic) Rigidbodys to other moving objects of any kind.
$$anonymous$$inematic Rigidbodys doesn't have anything to do with physics, the only connection is they can wake up non kinematic Rigidbodies. That's all they're used for. That means you can parent them like any normal GameObject, even as a child of a non kinematic Rigidbody.
Non kinematic Rigidbody represents physics objects. They are always simulated in world-space. Their position / velocity / angularVelocity belong the world. If you parent such an object to another moving object it will screw up the physics-based movement since the parent's movement / rotation is just "added" on top of the physics-simulation.
You can of course parent non kinematic Rigidbody to static objects for grouping purposes, but they will still move on their own.
Bunny33. What about attaching a normal rigidbody to a kinematic rigidbody using a configurable joint? Do you think that would work for moving objects? I mean, if the kinematic rigidbody were moved via a character controller or directly with transform, translate, wouldn't the attached rigidbody trail along and still be affected by physics?
Answer by Anxo · Dec 28, 2011 at 12:25 AM
I would assume that if you have a rigidbody the child of another rigid body, imagine a small box that is a child of a big box next to each other. and they are both effected by gravity, when they hit the floor the big box would influence the movement of the small box conflicting with the physics calculations and thus giving you unpredictable and unrealistic results.
If this is the answer then this would not apply to Kinematic Rigidbodies as their animations are not calculated.
Just my guess.
What if it's a fixed joint essentially two objects are treated as one combined object?
The documention on Fixed Joint gives a few tips on that. If you want the joint to be broken under a certain force / torque, or you want to avoid parenting because it would (1) clutter your hierarchy or cause unintuitive parenting, (2) cause scaling issues (child should not scale with parent) or (3) you want to provide symmetric control to both objects (two characters stuck to each other but both can still slowly move and drag the other character), then fixed joint is useful, but you will need a rigidbody on both objects.