Moving Spatials Physics


I want to open/close door by a mouse click & i implemented it by rotate the door node & it works well but the physics don’t obey the rotation done on it.
& still blocks the original position of the door.

This is the code for it:
[java]Node Door = (Node) assetManager.loadModel(“Models/Doors/Door.mesh.j3o”);
Door.setLocalTranslation(0f, 0f, -0.95f);
Door.rotate(new Quaternion().fromAngleAxis(180f * FastMath.DEG_TO_RAD, Vector3f.UNIT_Z));
Door.rotate(new Quaternion().fromAngleAxis(90f * FastMath.DEG_TO_RAD, Vector3f.UNIT_Y));
Door.setLocalScale(0.002f, 0.002f, 0.002f);

    Node DoorHinge = new Node("DoorHinge");
    DoorHinge.setLocalTranslation(3.12f, 2.37f, 29.7f);

    CollisionShape DoorShape = CollisionShapeFactory.createDynamicMeshShape(Door);
    RigidBodyControl DoorBody = new RigidBodyControl(DoorShape, 0);


    rootNode.getChild(DoorHinge).rotate(new Quaternion().fromAngleAxis(90f * FastMath.DEG_TO_RAD, Vector3f.UNIT_Y));


Thanks In Advance,

Set it to kinematic


Another info,

when using physics debugging, there is no physics on the entrance after opening door but still cannot enter.

If I remember well, it is specified in the tutorial not to mode the node, but only rely on the RigidBody to do so…
Here is the link :
So you should try something like DoorBody.setPhysicalRotoation(…)

Just do what @wezrule said.

1 Like

@wezrule That works fine :slight_smile:
Thank you very much :))