setKinematicSpatial with Animation [SOLVED]

Dear experts,

I am trying to find a way how to perform action with doors.

Currently I implemented two animations, which do open and close door.
Then I realized the RigidBodyControl applied to the door does not change its position.

Then I found the method setKinematicSpatial, but it also does not work.
Does it just never work with animation or it is me who misses something?
Here is my code:

RigidBodyControl innerDoorPhy = new RigidBodyControl(0f);
innerDoor.addControl(innerDoorPhy);

innerDoorPhy.setSpatial(innerDoor);
// This does not work whenever it is false or true
//    innerDoorPhy.setKinematic(true);
innerDoorPhy.setKinematicSpatial(true);
this.getPhysicsSpace().add(innerDoorPhy);

How do you usually implenent it? The door should have 3 states: locked, opened, closed.
Locked shoult not open by click, otherwise it should close if opened or open if closed

1 Like

Im not sure an animation is the way to do a door.
https://jmonkeyengine.github.io/wiki/jme3/advanced/hinges_and_joints.html

Only static objects have a mass of 0.
https://jmonkeyengine.github.io/wiki/jme3/advanced/physics.html#kinematic-vs-dynamic-vs-static

2 Likes

Hi Mitm,

thanks a lot for help. I have found these threads before, was just wondering as animations seemed to me also to rotate the spatial. But probably finding out how to apply animation bone rotation to rigid body attached is more complicated as just attach an AbstractControl to spatial and make it rotate by specific action.

Thanks again!

1 Like