Could someone tell me what reaction force/torque actually does to a joint and how it can be used to break one?
@captsmitty77 I haven’t use reactionForce or reactionTorque before, but I created a demo to use reactionForce. I haven’t quite figured out what’s happening when I vary the values. Once I understand what’s happening, I’ll post the results unless someone else responds first. Just wanted to let you know your question isn’t being ignored.
Ok, thanks
@captsmitty77 Here’s my demo. From what I can tell, reactionForce is the force needed to break the joint. In my demo, when the ball hits the joint, I display the force needed to break the joint at the top of the screen. It looks like you have to check that value and break the joint (destroy) it yourself. In the demo, you can slide the “limit” so the reactionForce is greater or less than the limit. If the reactionForce is less than the limit, I destroy the joint. I thought all of this was going to be automatic, but I don’t think it is.
supportedOrientations(LANDSCAPE_ANY)
function setup()
physics.continuous=true
parameter.integer("limit",-100,0,-100)
parameter.action("drop",setup1)
setup1()
end
function setup1()
m=0
if b1 then
b1:destroy()
b2:destroy()
b3:destroy()
e:destroy()
p1:destroy()
p2:destroy()
j1:destroy()
j2:destroy()
j3:destroy()
end
b1=physics.body(CIRCLE,10)
b1.x=250
b1.y=255
b1.type=STATIC
b2=physics.body(CIRCLE,10)
b2.x=450
b2.y=255
b2.type=STATIC
b3=physics.body(CIRCLE,10)
b3.x=350
b3.y=HEIGHT
e=physics.body(EDGE,vec2(0,100),vec2(WIDTH,100))
p1=physics.body(POLYGON,vec2(0,0),vec2(100,0),vec2(100,10),vec2(0,10))
p1.x=250
p1.y=250
p2=physics.body(POLYGON,vec2(0,0),vec2(100,0),vec2(100,10),vec2(0,10))
p2.x=350
p2.y=250
j1=physics.joint(WELD,p1,p2,p2.position-vec2(0,-5))
j2=physics.joint(REVOLUTE,p1,b1,p1.position-vec2(0,-5))
j3=physics.joint(REVOLUTE,p2,b2,p2.position-vec2(-100,-5))
end
function draw()
background(40, 40, 50)
fill(255)
stroke(255)
strokeWidth(2)
ellipse(b1.x,b1.y,20)
ellipse(b2.x,b2.y,20)
ellipse(b3.x,b3.y,20)
line(0,100,WIDTH,100)
if j1 then
r=j1.reactionForce -- force needed to break the joint
if r~=nil then
m=math.min(m,r.x)
if r.x<limit then -- check limit
j1:destroy() -- destroy joint
end
end
end
text(string.format("%d",m),WIDTH/2,HEIGHT-100)
pushMatrix()
translate(p1.x,p1.y)
rotate(p1.angle)
line(0,0,100,0)
line(100,0,100,10)
line(100,10,0,10)
line(0,10,0,0)
popMatrix()
pushMatrix()
translate(p2.x,p2.y)
rotate(p2.angle)
line(0,0,100,0)
line(100,0,100,10)
line(100,10,0,10)
line(0,10,0,0)
popMatrix()
end
You may need to add weight to the object hitting the joint, if that is possible in codea. Without making the object have a decent density, its like trying to break a chain with a ping pong ball.
@Crumble I can add mass to the ball. The just means that the force to break the joint is lower. The purpose of the demo is to show the force needed to break the joint. By changing the slider limit, I’m showing the breaking of the joint when the force exceeds the limit I set. Actually, there is nothing magical about the force. I can break the joint anytime I want just by destroying it. At first I thought the physics engine would break the joint, but it doesn’t. When I first started writing the demo, I did add mass to the ball and it would go thru the joint but the joint didn’t break. That’s when I realized that I had to break the joint myself and the reactionForce was what I needed to look at.
After thinking about this some more, the value that is shown at the top of the screen is the force of the ball hitting the joint. If I add more mass to the ball, the force is greater. I can pick any value I want when to break the joint since I’m the one breaking the joint. If I add to much mass to the ball and I don’t break the joint, the ball just passes thru the joint anyways. So to make it realistic, I have to pick the breaking value. Depending on what’s trying to get thru the joint will determine the limit I want to use to destroy the joint.