Beispiel #1
0
        private void Solve(SpringBehavior behavior)
        {
            //Calculate the new velocities.
            for (int i = 0; i < 3; i++)
            {
                Vector3 velocity = behavior.Velocities[i];
                Vector3 value    = behavior.Values[i];

                //Calculate the new velocity and value.
                velocity = (velocity - value) * behavior.Spring[i];
                value   += velocity * Time.deltaTime * behavior.Damping[i];

                behavior.Velocities[i] = velocity;
                behavior.Values[i]     = value;
            }
        }
Beispiel #2
0
        private Vector3[] UpdateBehavior(SpringBehavior behavior)
        {
            if (behavior.Disable)
            {
                return(new Vector3[3]);
            }

            //Add the new velocities.
            Vector3[] velocities = behavior.Velocities;
            velocities[0] += behavior.Move();
            velocities[1] += behavior.Rotate();
            velocities[2] += behavior.Scale();

            //Add to the new transform.
            Solve(behavior);
            return(behavior.Values);
        }