Beispiel #1
0
        public static Vector3 MoveOnPath(Spline.Path pts, Vector3 currentPosition, ref float pathPosition, ref Quaternion rotation, float maxSpeed, float smoothnessFactor, EasingType ease, bool easeIn, bool easeOut)
        {
            Vector3 vector = Spline.MoveOnPath(pts, currentPosition, ref pathPosition, maxSpeed, smoothnessFactor, ease, easeIn, easeOut);

            rotation = ((!vector.Equals(currentPosition)) ? Quaternion.LookRotation(vector - currentPosition) : Quaternion.identity);
            return(vector);
        }
Beispiel #2
0
 public static Vector3 InterpConstantSpeed(Spline.Path pts, float t, EasingType ease, bool easeIn, bool easeOut)
 {
     t = Spline.Ease(t, ease, easeIn, easeOut);
     if (pts.Length == 0)
     {
         return(Vector3.zero);
     }
     if (pts.Length == 1)
     {
         return(pts[0]);
     }
     if (pts.Length == 2)
     {
         return(Vector3.Lerp(pts[0], pts[1], t));
     }
     if (pts.Length == 3)
     {
         return(QuadBez.Interp(pts[0], pts[2], pts[1], t));
     }
     if (pts.Length == 4)
     {
         return(CubicBez.Interp(pts[0], pts[3], pts[1], pts[2], t));
     }
     return(CRSpline.InterpConstantSpeed(Spline.Wrap(pts), t));
 }
Beispiel #3
0
        public static Vector3 MoveOnPath(Spline.Path pts, Vector3 currentPosition, ref float pathPosition, float maxSpeed, float smoothnessFactor, EasingType ease, bool easeIn, bool easeOut)
        {
            maxSpeed    *= Time.deltaTime;
            pathPosition = Spline.Clamp(pathPosition);
            Vector3 vector = Spline.InterpConstantSpeed(pts, pathPosition, ease, easeIn, easeOut);
            float   magnitude;

            while ((magnitude = (vector - currentPosition).magnitude) <= maxSpeed && pathPosition != 1f)
            {
                pathPosition = Spline.Clamp(pathPosition + 1f / smoothnessFactor);
                vector       = Spline.InterpConstantSpeed(pts, pathPosition, ease, easeIn, easeOut);
            }
            if (magnitude != 0f)
            {
                currentPosition = Vector3.MoveTowards(currentPosition, vector, maxSpeed);
            }
            return(currentPosition);
        }
Beispiel #4
0
 public static Vector3 InterpConstantSpeed(Spline.Path pts, float t, EasingType ease, bool easeIn)
 {
     return(Spline.InterpConstantSpeed(pts, t, ease, easeIn, true));
 }
Beispiel #5
0
 public static Vector3 InterpConstantSpeed(Spline.Path pts, float t)
 {
     return(Spline.InterpConstantSpeed(pts, t, EasingType.Linear));
 }
Beispiel #6
0
 public static Vector3 Velocity(Spline.Path pts, float t, EasingType ease, bool easeIn)
 {
     return(Spline.Velocity(pts, t, ease, easeIn, true));
 }
Beispiel #7
0
 public static Vector3 Velocity(Spline.Path pts, float t)
 {
     return(Spline.Velocity(pts, t, EasingType.Linear));
 }
Beispiel #8
0
 public static Quaternion RotationBetween(Spline.Path pts, float t1, float t2, EasingType ease, bool easeIn, bool easeOut)
 {
     return(Quaternion.LookRotation(Spline.Interp(pts, t2, ease, easeIn, easeOut) - Spline.Interp(pts, t1, ease, easeIn, easeOut)));
 }
Beispiel #9
0
 public static Quaternion RotationBetween(Spline.Path pts, float t1, float t2, EasingType ease, bool easeIn)
 {
     return(Spline.RotationBetween(pts, t1, t2, ease, easeIn, true));
 }
Beispiel #10
0
 public static Quaternion RotationBetween(Spline.Path pts, float t1, float t2)
 {
     return(Spline.RotationBetween(pts, t1, t2, EasingType.Linear));
 }
Beispiel #11
0
 public static Vector3 MoveOnPath(Spline.Path pts, Vector3 currentPosition, ref float pathPosition, ref Quaternion rotation, float maxSpeed, float smoothnessFactor, EasingType ease, bool easeIn)
 {
     return(Spline.MoveOnPath(pts, currentPosition, ref pathPosition, ref rotation, maxSpeed, smoothnessFactor, ease, easeIn, true));
 }
Beispiel #12
0
 public static Vector3 MoveOnPath(Spline.Path pts, Vector3 currentPosition, ref float pathPosition, ref Quaternion rotation, float maxSpeed)
 {
     return(Spline.MoveOnPath(pts, currentPosition, ref pathPosition, ref rotation, maxSpeed, 100f));
 }
Beispiel #13
0
 public static Vector3 MoveOnPath(Spline.Path pts, Vector3 currentPosition, ref float pathPosition, float maxSpeed, float smoothnessFactor)
 {
     return(Spline.MoveOnPath(pts, currentPosition, ref pathPosition, maxSpeed, smoothnessFactor, EasingType.Linear));
 }
Beispiel #14
0
 public static Vector3 Interp(Spline.Path pts, float t, EasingType ease)
 {
     return(Spline.Interp(pts, t, ease, true));
 }
Beispiel #15
0
 public static Vector3 MoveOnPath(Spline.Path pts, Vector3 currentPosition, ref float pathPosition)
 {
     return(Spline.MoveOnPath(pts, currentPosition, ref pathPosition, 1f));
 }