I'm having some difficulties with Box2D DistanceJoints, I'm trying to create a rope using DistanceJoints connecting some bodies together but the length of joints between bodies change due to weight of bodies, is there any way to prevent joint lengths from changing?
I've faced the same problem, and what I've done was using DistanceJoint, with the frequencyHz set to 60 (or more) and the dampingRatio set to 0.
Imagine your distanceJoint as a rubber thread.
Higher frequencyHz makes thread more persistent.
Lower dampingRatio make it sooner for the thread gain original length after being stretched.
For those who may encounter this problem in the future: I just changed my approach, I used some
Revolute Joint to connect bodies together and mark all bodies as sensor so that they don't collide with each other (tell me if you any better way to avoid collision of the rope parts), and use boxes to fill the space between joints (previously it was Distance joints connecting circle shapes). Having density set to non-zero value the result looks like a real rope.
I was struggling with ropes in Box2D until I discovered that a joint's "strength" is proportional to the mass of the bodies it is connected to. The solution that worked for me was just to increase the density of the rope until it was strong enough to hold other objects up.