How To Create Animations In Game?

I’m trying to create a simple replay system just for learning purposes. I have a rigidbody with a script attached that saves it’s position to an array every tenth of a second and then creates an animation clip when complete. Now I want to know if it’s possible to create keyframes with the positions I’ve recorded, or am I going about this the wrong way? (C#)

there are examples in the scripting reference for the keyframe constructor

is that the kind of thing you are looking for?

Thanks, I’ve just tried that although I don’t really understand how you can create a keyframe with only a value and a time like in the example so how would you do it with a Vector3 and a time? I would have thought that I could do something like this:

ks = new Keyframe.Transform.position(i, Vector3);

instead it looks like it can only take a float so would I have to create multiple AnimationCurves for X,Y and Z and use them like this:
transform.position = new Vector3(Time.time, anim.Evaluate(Time.time), 0);