A body "chained" to a mouse-controlled body

Hey guys, I'm decent at ActionScript and a total novice at 2D physics engines. I'm having trouble prototyping a game idea of mine.

I want to have a small, mouse-controlled circle that is "chained" to a heavier rectangle body. I want the circle to follow the mouse pretty closely, but I want the "chain" link between the rectangle to be stronger than the link between the circle and the mouse.

So if the rectangle is sitting on the ground, I'd like to be able to move the circle around freely within the range of the "chain", but if I drag the circle so the "chain" is taut, I can only drag the circle (and the rectangle with it) slowly. If the rectangle is falling, I want the circle to be dragged down with it (overpowering the mouse control.)

I've been moving the circle around with the MouseJoint, and I've tried a DistanceJoint as the "chain" between the circle and rectangle, but that's not exactly what I'm going for (I'd need a MaxDistanceJoint-type thing, I think).

I've also tried a "chain" of bodies linked by RevoluteJoints, like the bridge in the testbed. This is close to what I'm going for, but the MouseJoint seems to frequently pull the RevoluteJoints apart, reducing my "chain" to a stretched-out, wriggling mess. I tried lowering the max force of the MouseJoint, but then the circle follows the mouse much too lazily.

If anyone has any tips for achieving the effect I'm going for, I'd really appreciate it.

Also, thanks for the great engine, port, and the helpful community. 🙂
Try using the mouse joint and tune the maxForce on b2MouseJointDef until you get the desired behavior.

Original thread: https://box2d.org/forum/viewtopic.php?t=297