Example #1
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);
        }
Example #2
0
 public static Vector3 InterpConstantSpeed(Spline.Path pts, float t, EasingType ease, bool easeIn)
 {
     return(Spline.InterpConstantSpeed(pts, t, ease, easeIn, true));
 }
Example #3
0
 public static Vector3 InterpConstantSpeed(Spline.Path pts, float t)
 {
     return(Spline.InterpConstantSpeed(pts, t, EasingType.Linear));
 }