Exemplo n.º 1
0
        private float CalculateDistance()
        {
            // Orbit distance
            var v1 = Utilities.Project2D(ValueOriginal.inverse.GetPosition(), Vector3.forward);

            v1.Normalize();

            var v2 = Utilities.Project2D(ValueTarget.inverse.GetPosition(), Vector3.forward);

            v2.Normalize();

            var angle = Mathf.Abs(Vector3.Angle(v1, v2));

            // Rotate distance
            v1 = Utilities.Project2D(ValueOriginal.GetPosition(), Vector3.forward);
            v1.Normalize();

            v2 = Utilities.Project2D(ValueTarget.GetPosition(), Vector3.forward);
            v2.Normalize();

            var angle2 = Mathf.Abs(Vector3.Angle(v1, v2));

            if (angle2 > angle)
            {
                angle = angle2;
            }

            var radius = (ValueOriginal.inverse.GetPosition().magnitude + ValueTarget.inverse.GetPosition().magnitude) / 2;

            var arcDist  = radius * angle;
            var lineDist = (ValueTarget.inverse.GetPosition() - ValueOriginal.inverse.GetPosition()).magnitude;

            return((lineDist > arcDist) ? lineDist : arcDist);
        }
Exemplo n.º 2
0
 public override void Revert()
 {
     transform.position = ValueOriginal.GetPosition();
     transform.rotation = ValueOriginal.GetRotation();
 }
Exemplo n.º 3
0
 public override void Revert()
 {
     transform.SetPosition(ValueOriginal.GetPosition(), SetGlobal);
     transform.SetRotation(ValueOriginal.GetRotation(), SetGlobal);
 }