Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Rope stretch problem
#1
Hello, I am making a rope length real-time update project, encountered some problems, I hope I can get help
Below is the method to dynamically change the length of the rope, which is performed in the Update, which cannot be changed。
Code:
public void ChangeRopeLength()
{
    restLength = Rope.restLength;
    currentLength = Rope.CalculateLength();
    diff = currentLength - restLength;

    if (diff > m_StretchThre)
        restLength += diff * Time.deltaTime * m_StretchSpeed;

    if (diff < m_ShortenThre)
        if (restLength > startLength)
            restLength += diff * Time.deltaTime * m_ShortenSpeed;

    m_RopeCursor.ChangeLength(restLength);

    ropeLength = Rope.restLength;

    //m StretchThre is 0.1,m_ShortenThre is -0.1,m_StretchSpeed and m_ShortenSpeed is 50.
}
This method only works if I set the value of Distance Constraints to 0.5 or less. If I set it to 1, the rope will stretch indefinitely. Even if I changed the m StretchThre in the top code to be large enough, it wouldn't work as well as I wanted.
I wonder what method I can use to change the rope length in Update when I change the Distance Constraints to 1,So that the length of the rope can be normal variation, rather than infinite elongation
Reply


Messages In This Thread
Rope stretch problem - by Agony - 19-03-2024, 07:13 AM
RE: Rope stretch problem - by josemendez - 19-03-2024, 07:28 AM
RE: Rope stretch problem - by Agony - 19-03-2024, 07:33 AM
RE: Rope stretch problem - by josemendez - 19-03-2024, 08:35 AM
RE: Rope stretch problem - by Agony - 19-03-2024, 09:24 AM
RE: Rope stretch problem - by josemendez - 19-03-2024, 09:35 AM