Ejemplo n.º 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);
        }
Ejemplo n.º 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));
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
 public static Vector3 InterpConstantSpeed(Spline.Path pts, float t, EasingType ease, bool easeIn)
 {
     return(Spline.InterpConstantSpeed(pts, t, ease, easeIn, true));
 }
Ejemplo n.º 5
0
 public static Vector3 InterpConstantSpeed(Spline.Path pts, float t)
 {
     return(Spline.InterpConstantSpeed(pts, t, EasingType.Linear));
 }
Ejemplo n.º 6
0
 public static Vector3 Velocity(Spline.Path pts, float t, EasingType ease, bool easeIn)
 {
     return(Spline.Velocity(pts, t, ease, easeIn, true));
 }
Ejemplo n.º 7
0
 public static Vector3 Velocity(Spline.Path pts, float t)
 {
     return(Spline.Velocity(pts, t, EasingType.Linear));
 }
Ejemplo n.º 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)));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 10
0
 public static Quaternion RotationBetween(Spline.Path pts, float t1, float t2)
 {
     return(Spline.RotationBetween(pts, t1, t2, EasingType.Linear));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 14
0
 public static Vector3 Interp(Spline.Path pts, float t, EasingType ease)
 {
     return(Spline.Interp(pts, t, ease, true));
 }
Ejemplo n.º 15
0
 public static Vector3 MoveOnPath(Spline.Path pts, Vector3 currentPosition, ref float pathPosition)
 {
     return(Spline.MoveOnPath(pts, currentPosition, ref pathPosition, 1f));
 }