Maximum distance joint

Is there something like max. distance joint? Or maybe with min. value too. the joint would behave just like distance joint, if 2 points got beyond this maximum distance, otherwise there would be free movement.

A good usage for this joint would be the rope simulation like in HL2 (Havok). There is no actual physical rope (actually, there is a simple physics for animating the graphic rope but that does nothing with physics engine). Rope allows you to move freely until the distance of jointed points is bigger than rope lenght (sure there is no actual rope collision but that might not be necessary)

So is there any way to do this in box2D?
Distance joints have a fixed distance, so are no good. Pulley joints are closer to what you want, as they allow max length for both ends of the pulley (and thus a min and max for one given end). Just attach the other end to a non-colliding light invisible object. But if I recall, pulley joints require the pulley itself to be fixed relative to the ground, which might be no good for you.

Perhaps you can hack together a new joint from the two of those. Or not, I've never understood the joint code myself.

There is a rope demo in the test bed which uses multiple short distance joints. It's not as you describe, but it is convincingly 'ropey'.
Prismatic joints can have limits assigned to them. But Prismatic joints also prevent relative rotation between the two bodies that are attached to each other.
Yes, that's right! You could use by connecting object A to a dummy by a prismatic joint, and the dummy to object B by a revolute joint. I'd forgotten that trick, but it has come up several times before on these forums. The two joints positions then become separated radial co-ordinates for object A, and their min and maxes work as you'd hope. Caveat: Stability might not be quite as great as a single joint.

I'm not sure whether the dummy object should be light or not, though. If it has significant mass, it might oddly effect the dynamics of the scene, but if is light (near zero mass), then I think that impairs the ability of the solver to propagate forces through it?
You can combine a revolute and a prismatic joint with a limit.

The pulley has a maximum distance constraint that could be refactored into a new joint type.
Yeah revolute and prismatic might work thanks
And what about welding 2 bodies together like they were 1? Sure i could use prismatic and distance but i find it unnecessarily CPU expensive.
The most effective way to do that is put all of the shapes involved into one body. You can create new shapes on one of the bodies in between physics timesteps, and remove the other one from the simulation.
Sure, but sometimes you need to put them together just for a small period of time..
A revolute joint with the min and max angle set to the same angle is the typical answer, though a similar trick works with other joints.

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