Joint breaking

Hello i need your help once again.

I have modified the TestPhysicsHingeJoint example and added two keys to move the top cube. Also on the bottom cube(hammerNode) i have applied a force so that the movement of the bottom cube fades out faster. I have noticed that when the bottom cube stops moving (even for a moment) the joint breaks and the top cube moves alone. I have tested other joint types such as PhysicsConeJoint and Physics6DofJoint and they both seem to have the problem.

Also is there another way to fade out the bottom cubes movement without applying the force?

Here's the modified example code

package physics;

import com.jme3.bullet.collision.shapes.BoxCollisionShape;
import com.jme3.bullet.joints.PhysicsHingeJoint;
import com.jme3.bullet.nodes.PhysicsNode;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.AnalogListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;

public class TestPhysicsHingeJoint extends SimpleBulletApplication implements AnalogListener {
    private PhysicsHingeJoint joint;
    private PhysicsNode holderNode;
    private PhysicsNode hammerNode;

    public static void main(String[] args) {
        TestPhysicsHingeJoint app = new TestPhysicsHingeJoint();

    private void setupKeys() {
        inputManager.addMapping("Lefts", new KeyTrigger(KeyInput.KEY_H));
        inputManager.addMapping("Rights", new KeyTrigger(KeyInput.KEY_K));
        inputManager.addMapping("Space", new KeyTrigger(KeyInput.KEY_SPACE));
        inputManager.addMapping("Left_move", new KeyTrigger(KeyInput.KEY_N));
        inputManager.addMapping("Right_move", new KeyTrigger(KeyInput.KEY_M));
        inputManager.addListener(this, "Lefts", "Rights", "Space", "Right_move", "Left_move");

    public void onAnalog(String binding, float value, float tpf) {
            joint.enableMotor(true, 1, .1f);
        else if(binding.equals("Rights")){
            joint.enableMotor(true, -1, .1f);
        else if(binding.equals("Space")){
            joint.enableMotor(false, 0, 0);
        else if(binding.equals("Right_move")){
           Vector3f v = holderNode.getLocalTranslation();
           holderNode.setLocalTranslation(v.x + value*speed, v.y, v.z);
        else if(binding.equals("Left_move")){
           Vector3f v = holderNode.getLocalTranslation();
           holderNode.setLocalTranslation(v.x - value*speed, v.y, v.z);

    public void onPreUpdate(float tpf) {

    public void onPostUpdate(float tpf) {

    public void simpleInitApp() {

    public void setupJoint() {

        Material mat = new Material(getAssetManager(), "Common/MatDefs/Misc/WireColor.j3md");
        mat.setColor("m_Color", ColorRGBA.Yellow);

        holderNode=new PhysicsNode(new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        holderNode.setLocalTranslation(new Vector3f(0f,0,0f));

        hammerNode=new PhysicsNode(new BoxCollisionShape(new Vector3f( .3f, .3f, .3f)),1);
        hammerNode.setLocalTranslation(new Vector3f(0f,-1,0f));

        joint=new PhysicsHingeJoint(holderNode, hammerNode, Vector3f.ZERO, new Vector3f(0f,-1,0f), Vector3f.UNIT_Z, Vector3f.UNIT_Z);

    public void simpleUpdate(float tpf) {
       Vector3f velocity = hammerNode.getLinearVelocity();
       float b=2;
       Vector3f force=new Vector3f(-velocity.x*b,-velocity.y*b,-velocity.z*b);
       hammerNode.applyContinuousForce(true, force);


And a screenshot.

I guess your PhysicsNode gets deactivated and does not move anymore because of this… Try calling physicsNode.setActive(true) on the lower box when you move the other box or lowering the deactivation threshold.



The PhysicsNode does not have .setActive(true) function.

I did physicsNode.activate() and it is working fine! I couldn't find how to lower the deactivation threshold but now it is ok.

Thank you very very much! :slight_smile: