Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Physics joints - disconnecting?

in Questions Posts: 81

Hi all,

I realize a code sample would probably help but, in general: when/how can a physics joint (REVOLUTE type) become separated? It there some force calculation? If so, is there a flag I can set on the physics bodies or joint to prevent separation? I am sure that I’ve created the joint properly, and the separation behavior is not consistent. It will happen during one execution, and then not on the next. And more often the joint remains connected. But sometimes it doesn’t.

Thanks!

Tagged:

Comments

  • dave1707dave1707 Mod
    Posts: 7,559

    Look in the reference under physics.joint. There’s a variable called reactionForce. That might be what you’re after.

  • dave1707dave1707 Mod
    Posts: 7,559

    You didn’t provide an example, so here’s one of mine that uses REVOLUTE. Drag your finger around the screen. The joints stay connected. But then I don’t know how much force your putting on your joints.

    displayMode(FULLSCREEN)
    
    function setup()
        physics.continuous=true
        physics.gravity(0,0)
        p1=physics.body(CIRCLE,10)
        p1.x=200
        p1.y=320
    
        p2=physics.body(CIRCLE,5)
        p2.x=200
        p2.y=300
        p3=physics.body(CIRCLE,5)
        p3.x=130
        p3.y=300
        p4=physics.body(CIRCLE,5)
        p4.x=270
        p4.y=300
    
        p5=physics.body(CIRCLE,5)
        p5.x=200
        p5.y=200
        p6=physics.body(CIRCLE,5)
        p6.x=100
        p6.y=200
        p7=physics.body(CIRCLE,5)
        p7.x=300
        p7.y=200
        jnt1=physics.joint(REVOLUTE,p1,p2,p1.position)
        jnt2=physics.joint(REVOLUTE,p2,p3,p2.position)
        jnt3=physics.joint(REVOLUTE,p2,p4,p2.position)
        jnt4=physics.joint(REVOLUTE,p2,p5,p2.position)
        jnt5=physics.joint(REVOLUTE,p5,p6,p5.position)
        jnt6=physics.joint(REVOLUTE,p5,p7,p5.position)
        fill(255)
        stroke(255)
        strokeWidth(2)
    end
    
    function draw()
        background(0)
        ellipse(p1.x,p1.y,20)
        ellipse(p2.x,p2.y,10)
        ellipse(p3.x,p3.y,10)
        ellipse(p4.x,p4.y,10)
        ellipse(p5.x,p5.y,10)
        ellipse(p6.x,p6.y,10)
        ellipse(p7.x,p7.y,10)
        line(p1.x,p1.y,p2.x,p2.y)
        line(p2.x,p2.y,p3.x,p3.y)
        line(p2.x,p2.y,p4.x,p4.y)
        line(p2.x,p2.y,p5.x,p5.y)
        line(p5.x,p5.y,p6.x,p6.y)
        line(p5.x,p5.y,p7.x,p7.y)
    end
    
    function touched(t)
        if t.state==MOVING then
            p1.linearVelocity=vec2(t.deltaX*20,t.deltaY*20)
        end
    end
    
Sign In or Register to comment.