Breakable Joints

Aug 5, 2010 at 9:23 PM

I recently converted my FP2.1 game over to FP3, and so far it's been a resounding success. There were a few quirks I had to put on the side while I figured out how FP3 did things, and over the past 2 weeks I've managed to fix all of them except one.

In my game I had a "bridge" type object, which was rickety and collapse if too much weight was on it. To accomplish this I had two joints attached to the bridge: 


    var joint = JointFactory.Instance.CreateFixedRevoluteJoint(Level.Simulator, body, body.Position );
    joint.Breakpoint = BreakPoint;
    joint.MaxImpulse = MaxImpulse;

    var joint2 = JointFactory.Instance.CreateFixedAngleLimitJoint(Level.Simulator, body, MinAngle, MaxAngle);

The second joint made it so the bridge couldn't rotate about the revolute joint's center, and the revolute joint set the values of the Break Point and Max Impulse, so that if too much weight was on it, the bridge would collapse.


However, I cannot seem to find a way in FP3 to accomplish this. There's a BreakableBody class, but that doesn't really seem to be what I'm looking for at first inspection, since I'm just holding the bridge segment in place attached to an imaginary world anchor. Does anyone have any ideas? None of the joints in FP3 seem to have the idea of "breakability" like the joints in FP2.1 did.


Thanks in advance!

Aug 6, 2010 at 7:55 AM

I looked on the Box2D forums, and you need to check Joint.GetReactionForce() and Joint.GetReactionTorque() each frame, and if it exceeds your limit you destroy it.

Depending on your needs it might be easy to create a new BreakableJoint class, which inherits from the joint you want to break. I plan on doing something similar myself when I get around to it.

Aug 6, 2010 at 1:20 PM
This could be implemented as a feature in FPE 3.x if needed.
Aug 6, 2010 at 5:46 PM
Ah cool, that works nicely. Thanks!
Sep 30, 2010 at 9:52 PM

I think it would be a lot more convent if joints had a breaking point again and could break by themselves.