Why is my Rigidbody child not moving with it's Rigidbody parent?

Apologies for a dumb question: I’m sure I’ve solved this problem before with characters on moving platforms, but nonetheless I’m getting behaviour that’s confusing me now.

I have two cubes stacked on top of each other, each with a box collider and rigidbody.

The upper cube is the child of the lower cube. Gravity on both rigidbodies is disabled.

In editor and play mode, moving the parent cube by dragging the transform widget moves the child cube (it inherits the transformation).

However, when I run the following simple test code on the parent (moving it with movePosition), the child cube remains motionless, failing to inherit the transformation of the parent.

private Rigidbody rb;
     public float percent = 0.0f;
     void Awake()
     {
         rb = GetComponent<Rigidbody>();
     }
     void Update()
     {
         percent += Time.deltaTime;
         rb.MovePosition(Vector3.MoveTowards(Vector3.up * 2 + Vector3.left * 4, Vector3.up * 2 + Vector3.right * 4, percent));
     }

As I say, I’m certain I’ve used something similar for characters and moving platforms before (parenting onCollisionEnter etc.)

What’s the obvious thing that I’m missing here? This shouldn’t be confusing me like it is…!

Did you try to look for a solution to your problem? I don’t play a lot with Unity’s physic system but here is what I found: Child rigidbody doesn't act normally when parent rigidbody moves

I hope this will solve your problem

1 Like

Hi @Oskar_Kasprzak ! That seems to contradict the docs, though, no?

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.

I saw the page you linked while doing some cursory research on this, but didn’t go deep into it as I was heading to bed at the time. I thought this would be a straightforward issue so I just posted and hit the hay. =) I’ll do some more research here. Thanks for your time!