Exemplo n.º 1
0
            public void Update()
            {
                var    x      = End1.Position - End2.Position;
                double length = x.Length();

                if (length <= TargetLength)
                {
                    return;
                }
                x = (x / length) * (length - TargetLength);
                var dv    = End2.Velocity - End1.Velocity;
                var force = Stiffness * x - dv * Damping;

                End1.ApplyForce(-force);
                End2.ApplyForce(force);
            }
Exemplo n.º 2
0
    public void Update()
    {
        var x = End1.Position - End2.Position;

        float length = x.magnitude;

        // these springs can only pull, not push
        if (length <= TargetLength)
        {
            return;
        }

        x = (x / length) * (length - TargetLength);
        var dv    = End2.Velocity - End1.Velocity;
        var force = Stiffness * x - dv * Damping;

        End1.ApplyForce(-force);
        End2.ApplyForce(force);
    }
Exemplo n.º 3
0
            public void Update()
            {
                var x = End1.Position - End2.Position;

                float length = x.Length();

                // springs are only able to pull but not able to push
                if (length <= TargetLength)
                {
                    return;
                }

                x = (x / length) * (length - TargetLength);
                var dv    = End2.Velocity - End1.Velocity;
                var force = Stiffness * x - dv * Damping;

                End1.ApplyForce(-force);
                End2.ApplyForce(force);
            }