-
-
Save bahadir/fe6cbea85aaf1f973dc1de792e9f5597 to your computer and use it in GitHub Desktop.
Non-linear interpolation between two vectors
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 System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class MoveCurve : MonoBehaviour { | |
public AnimationCurve curve; | |
public Vector3 posStart; | |
public Vector3 posStop; | |
private float elapsed = 0f; | |
void Update () { | |
float t = curve.Evaluate(elapsed / 2f); | |
transform.position = Vector3.Lerp(posStart, posStop, t); | |
elapsed += Time.deltaTime; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment