Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.43 KB | None | 0 0
  1. public static IEnumerator MoveTo(Vector3 from, Vector3 to, float duration, Action<Vector3> onChange)
  2.     {
  3.         float t = 0;
  4.         Vector3 currentPosition = from;
  5.        
  6.         while (t < duration)
  7.         {
  8.             currentPosition = Vector3.Lerp(from, to, (t / duration));
  9.             onChange(currentPosition);
  10.             t += Time.deltaTime;
  11.             yield return null;
  12.         }
  13.         onChange(to);
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement