I’ve been messing around the engine for a few days trying to get a simple moving platform/elevator to work, and eventually found out kinematic rigid bodies just does not work right.
I have a setup with a kinematic rigid body and a script attached that moves it around, and a dynamic body placed on top. So that body begins constatly bouncing from the platform when the platform moves down, or “sinking” in when going up. The same scene build in the clean Bullet 2.82 works perfectly fine, at least it seems so.
In the end I found that the body’s interpolation position is messed in RigidBody::SetPosition, thus negating the velocity approximation by the physics engine and causing movement artifacts with kinematic objects when controlled externally (and they are actually meant for that). I end up with a workaround
I kind of understand why this was made, but this seriously breaks the kinematic objects. I suppose there should be some more solid solution though.
BTW, why do we want to update inertia tensor on position change?
Here’s the test scene:
<removed “as an anti-spam measure, sorry”>
Well, since this is just a workaround, i thought there might be a better solution, since this one could probably cause jittering again at step zero. Not sure though. And another strange thing: the platform itself still jitter a bit when moving, you can clearly see that when stepping as a first person character on the platform. I was able to completely get rid of it by disabling interpolation in physicsWorld, but still… Any ideas?
Went through Bullet documentation and found out that for kinematic rigidbodies, we should not update the rigidbody transform from the scene node. Instead Bullet will continuously ask for it. This change has been pushed. So now you should be able to set the scene node position in Update() and the animation will be smooth. I noticed however that the cube bounced differently if the lift animation is done in Update() versus FixedUpdate(), that happens (I assume) because we’re now basically moving the scene node with higher frequency than Bullet keeps track of.
Oops, i somehow did not realize we were actually changing the world transfromation of the body itself there. So, yeah, i like the new patch much better. Thank you for quick response!
And i still believe updateInertiaTensor is not needed in SetPosition, because it does not depend on body position, as far as i can see