Create a keyframe.
using UnityEngine;
using System.Collections;
public class example :
MonoBehaviour {
private AnimationCurve anim;
private Keyframe[] ks;
void Start() {
ks =
new Keyframe[50];
int i = 0;
while (i < ks.Length) {
ks[i] =
new Keyframe(i,
Mathf.Sin(i), 90, 90);
i++;
}
anim =
new AnimationCurve(ks);
}
void Update() {
transform.position =
new Vector3(
Time.time, anim.Evaluate(
Time.time), 0);
}
}