Created
July 7, 2020 17:21
-
-
Save vysinsky/12f7b18e9a26c89854a458f6f142f708 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
namespace Animations | |
{ | |
public class PositionTransition | |
{ | |
private readonly float _duration; | |
private readonly Vector3 _from; | |
private readonly Vector3 _to; | |
private float _animationTime; | |
public PositionTransition(Vector3 from, Vector3 to, float duration) | |
{ | |
_from = from; | |
_to = to; | |
_duration = duration; | |
} | |
public Vector3 GetCurrentPosition(float deltaTime) | |
{ | |
_animationTime += deltaTime / _duration; | |
return Vector3.Lerp( | |
_from, | |
_to, | |
_animationTime | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment