Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static IEnumerator MoveTo(Vector3 from, Vector3 to, float duration, Action<Vector3> onChange)
- {
- float t = 0;
- Vector3 currentPosition = from;
- while (t < duration)
- {
- currentPosition = Vector3.Lerp(from, to, (t / duration));
- onChange(currentPosition);
- t += Time.deltaTime;
- yield return null;
- }
- onChange(to);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement