(09-10-2018, 08:18 AM)Evgenius Wrote: Hello!
I'm creating a crane and I need to pull big weights with the hook attached to two ropes. But the more weight I attach, the more stretchy become the ropes. Tethers are not a choice since I need to reel and extend the ropes. I've tried to increase distance constrain iterations, but it cost much of performance and doesn't work for all weights. Does anybody have a solution or any ideas?
This is a
fundamental issue of all iterative physic engines, which account for nearly 100% of realtime physics: the more you increase the mass ratio between two objects, the slower convergence becomes (and so, chains of constraints become stretchy).
In most games this is avoided by one or a combination of:
- Reducing the fixed timestep (Unity's default is 0.02, try 0.01 or 0.005). See:
https://docs.unity3d.com/Manual/class-TimeManager.html
- Reducing the rope resolution so that there are less particles in the rope, so convergence speed is not that much of a problem anymore.
- Clamping the mass ratio between the rope and the weight attached to it (the usual maximum ratio is 1/10).
- Attach the weight directly to the top of the crane by using a spring joint, and update the spring length so that it matches the rope's lenght. This way, the weight is supported by a single joint instead of a chain of distance constraints. This is similar to the concept behind tether constraints.
In extreme cases where none of these are acceptable, ditch iterative physics entirely and switch to a specialized direct solver. I've yet to see one of these in a game due to their bad (for game standards) performance, relatively common in engineering/industrial scenarios though.