Why does rigidbodies lag behind when connected to kinematic rigidbodies?

The title says it. When I attach a rigidbody to a kinematic rigidbody with a joint inside a vehicle, it lags behind when I drive the vehicle forwards. Why does it do this?

Here is a picture showing it, the kinematic rigidbody is controllable by a script with the mouse because it’s a turret. And the turret itself is a physical rigidbody that is attached to the kinematic rigidbody. But it lags behind when I travel fast. Yet again, why does it do this?

4 years late, but since I just came across this problem I may as well answer!

There are 2 reasons that this can happen as far as I can see:

  1. the kinematic body is being moved in the Update function and not FixedUpdate. Since the Physics system updates after each FixedUpdate, and Update is after Physics, that would cause a one-frame lag.

  2. the kinematic body which has the dynamic body attached to it is itself the child of a rigid body (the trailer in your image). In this case, the kinematic body’s position is not updated as part of the physics update because physics does not know about the attachment. Instead the kinematic body’s position is updated after physics, but that’s too late for it to affect any joints attached to it.

Your problem is likely the second one, and I think that unfortunately the only way to retain the physics connection is to have dynamic bodies all the way through. So, change your kinematic body to a non-kinematic one and attach it to its parent with a FixedJoint.

Note you can set the ConnectedMassScale on a joint to very small if you want to prevent the child object from affecting the motion of the parent. If that sounds the wrong way round it’s because ConnectedMassScale is a scale on the inverse mass, so what we are doing is pretending that the connected (parent) object has extremely large mass.