11-05-2020, 09:28 AM
(This post was last modified: 11-05-2020, 09:33 AM by josemendez.)
(11-05-2020, 09:23 AM)Warren Wrote: How to check if it is pulling?
You could simply calculate strain. Strain is a measure of how far from its rest "shape" a material is. So a strain > 1 indicates the rope is overstretched, a strain < 1 indicates compression, and 1 indicates no strain at all.
Code:
float strain = rope.CalculateLength() / rope.restLength;
Note however that using the strain to drive a rope cursor won't pull the rope back, keeping it tense at all times. I think you're going for a "Rope Around" type of game: the rope is simply longer than you see on screen, a rigidbody weight is pulling downwards. This keeps the rope tense at all times, allows the rope to become "longer" when you pull, and does not require dynamic resizing.