Skip to content

Instantly share code, notes, and snippets.

@bahadir
Last active May 18, 2018 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bahadir/fe6cbea85aaf1f973dc1de792e9f5597 to your computer and use it in GitHub Desktop.
Save bahadir/fe6cbea85aaf1f973dc1de792e9f5597 to your computer and use it in GitHub Desktop.
Non-linear interpolation between two vectors
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