The physics behavior doesn’t provide that joint.
A few ideas come to mind though.
1. Is to do event based physics using verlet. I’ve made rope examples that do that. It’s as simple as if the distance is greater than a certain amount the objects are moved toward each other to correct that, then the velocities are updated. The cons are it’s independent of the physics behavior and working with ridged bodies will require more code.
2. Joints in the physics engine are done with impulses behind the scene so in theory you could make the joint you want with that. I fiddled with the idea a bit and something like an impulse of (distance-100)/100 toward the other object seems to work but is bouncy. For better results we could copy what impulses box2d calculates for such a joint.
Edit:
If d is the distance between the objects and ang is the angle between them, then the impulse should be the following when dist<100. At least from what I’ve read.
ImpulseAtoB= -(d-100+(A.vx-B.vx)*cos(ang)+(A.xy-B.vy)*sin(ang))/(1/A.mass+1/B.mass)
I’ll test this later. The units may be off.