When to update location on KinematicRagdollControl?

My aim is to have a character but that becomes a ragdoll when it dies.

So I have gone for KinematicRagdollControl, but this means I have to move it about, which is fine except I’m not sure where to do this.

It works OK in the simpleUpdate() method with a setLocalTranslation, but it means that the collisions the character has is a bit hit and miss. It obviously would be better in a physics tick.

So I added a physics tick listener (bulletAppState.getPhysicsSpace().addTickListener(this)) and moved the setLocalTranslation in there but it crashes out with this error:

java.lang.IllegalStateException: Scene graph is not properly updated for rendering.

State was changed after rootNode.updateGeometricState() call.

Make sure you do not modify the scene from another thread!

So how can I move my character around with the physics ticks? Am I going about it wrong with the KinematicRagdollControl? I’d like to use the CharacterControl, but then can I easily make it rag doll when the character dies? Is that the better way to do it?


The first method is good, the physics is synced “as soon as possible” anyway. Since the object is in kinematic mode it images the spatials (and in this case bones as well) locations.