09-02-2024, 08:32 AM
(This post was last modified: 09-02-2024, 08:32 AM by josemendez.)
(08-02-2024, 03:14 PM)lela_tabathy Wrote: If I may hijack this thread, I‘m trying something similar where I‘m reducing the ropes length through Cursor, while the end is attached to a fixed point. I need to make sure the rope doesn‘t go through colliders along the way and basically stops the Cursor. Here‘s a sophisticated drawing, the first one shows the intended behaviour when the rope cursor is at the point where the rope shouldn’t shorten any further.
Any tips?
I‘m currently doing this by checking the rest length and not allowing further shortening that way. But that way I have to trial & error the min length and it‘s not very scalable.
You could compare the rope's rest length to its current length, to see if the rope is overly stretched. If it is, stop the cursor (or even reel out a bit of rope length to reduce strain).
Code:
float strain = rope.CalculateLength() / rope.restLength; // this will be >1 when stretched, <1 when compressed, 1 when under no forces.
let me know if you need further help,
cheers