Ejemplo n.º 1
0
        // Update is called once per frame
        void Update()
        {
            // get current and rest lengths:
            float length     = rope.CalculateLength();
            float restLength = rope.restLength;

            // calculate difference between current length and rest length:
            float diff = Mathf.Max(0, length - restLength);

            // if the rope has been stretched beyond the reel out threshold, increase its rest length:
            if (diff > outThreshold)
            {
                restLength += diff * outSpeed;
            }

            // if the rope is not stretched past the reel in threshold, decrease its rest length:
            if (diff < inThreshold)
            {
                restLength -= diff * inSpeed;
            }

            // set the new rest length:
            cursor.ChangeLength(restLength);
        }