I’m new in unity. Recently, I am working on a project that we need to use cycle offset as the extrapolation between given animation curve. For now, I already performed an animation I need in loop mode. But when the animation ends, it will go back to the beginning position. So I need the cycle offset to keep it moving.`empty.AddComponent();
Animation anim = empty.GetComponent();
AnimationCurve curve;
// create a new AnimationClip
AnimationClip clip = new AnimationClip();
clip.legacy = true;
// create a curve to move the GameObject and assign to the clip
Keyframe[] keys;
keys = new Keyframe[2];
keys[0] = new Keyframe(0.0f, 0.0f);
keys[1] = new Keyframe(1.0f, 1.5f);
curve = new AnimationCurve(keys);
clip.SetCurve("", typeof(Transform), "localPosition.z", curve);
clip.wrapMode = WrapMode.Loop;
anim.AddClip(clip, clip.name);
anim.Play(clip.name);`
empty is the name of gameobject I want to move.