[jme3] joints weird behaviour

Hello everybody,

There is something I don’t quite understand: when i try to reset the position of a ragdoll (by moving and rotating every limb to a “legal” starting position), it sometimes literally explode, every piece is thrown reallllllyyy far !

So, what is the proper way to reset the position of jointed pieces in jme3 ??

Should i use setLocalTranslation or setPhysicsPosition ? and setLocalRotation or setPhysicsRotation ? So far, it seems that the setPhysics methods work better… I currently also use this:

[java] for (int i=0;i<this.children.size();i++) {

((PhysicsNode) this.children.get(i)).setLinearVelocity(Vector3f.ZERO);

((PhysicsNode) this.children.get(i)).clearForces();

((PhysicsNode) this.children.get(i)).setAngularVelocity(Vector3f.ZERO);


To calm down the pieces !

I’m sure this isn’t the right way to use the physics engine.

So what should i do guys ??


No, this is correct. Thing is that when you move physics nodes (especially with joints) they may build up forces that have to be cleared. SetPhysicsLocation only applies the location directly, when you use setLocalTranslation its only applied in the next update loop, so the forces get applied again. So when using setLocalTranslation you would probably have to do the clearForces stuff in a callable for the PhysicsSpace so it happens after the update. Still, you should check if the locations you put the ragdoll in are really correct and working, too high forces mostly hint at “impossible” physics situations you created.

What happens is when a ragdoll ‘explodes’ is that you’ve created an impossible situation for the physics engine. Check that joints are not through eachother and that your ragdoll is not accidentally in another object.

Hum, but i’m pretty sure the ragdoll is in a possible situation as i wait for it to reach a stable situation, then i save the coords (and rotation) of every limbs, and then i load them. I just move the ragdoll to a state he reached by himself.

It seems that the ragdoll only explode when i try to change is location while it is moving fast…

Any ideas ? Is there anything else I should reset in the physics engine before moving jointed pieces ?

Thanks !

I believe i’m making some progress but still, i’m still facing strange joint behaviour :confused: what do you mean by do the clearForces stuff in a callable for the PhysicsSpace so it happens after the update ??

Like this (dont use fut.get()!)

[snippet id=“10”]