Skip to content

Instantly share code, notes, and snippets.

@vysinsky
Created July 7, 2020 17:21
Show Gist options
  • Save vysinsky/12f7b18e9a26c89854a458f6f142f708 to your computer and use it in GitHub Desktop.
Save vysinsky/12f7b18e9a26c89854a458f6f142f708 to your computer and use it in GitHub Desktop.
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