Hi, I have a animation curve setup as below
var Bobcurve : AnimationCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5, 1), new Keyframe(1, 0), new Keyframe(1.5, -1), new Keyframe(2, 0));
Is it possible to alter the second and fourth values in Update()
Thanks.
OK done it …
function LateUpdate ()
{
FindOrAddKey(Bobcurve, 0.5, _slider.value);
FindOrAddKey(Bobcurve, 1.5, -_slider.value);
}
// ----------------------------
function FindOrAddKey(curve: AnimationCurve, time: float, value: float)
{
for (var i=0; i < curve.keys.Length; i++)
{
if (curve.keys[i].time == time)
{
curve.RemoveKey(i);
break;
}
}
var key : float = curve.AddKey(time, value);
}
// ----------------------------