Bake/Cache animator output

I have a data file that contains a “timeline” of motion vectors that I want to use to generate animation for a character. I need to be able to jump to random points in time, which I’m not sure I can do with the animator; I’m assuming things like blending is dependent on the changes of the animator parameters from one sample to the next.

My current idea is to feed the animator the timeline of parameter changes (not in real-time) and record the character transform with each update. The final result would be a cache of what the animator generated for the given sequence it processed. Ideally I could write this to disc and load the animation at the appropriate time, but if I had to create the cache and read from it during the same game session that’s okay.

Has anyone ever tried to dynamically create an animation clip? I’m not sure it’s possible. Any thoughts on how to do this or how to jump in time while using the animator is appreciated.

I’ve only done teeny tiny bits of playing around with this, but I think this API might be what you are looking for: Unity - Scripting API: GameObjectRecorder

Now, that being said - depending on your scenario you may want to look at runtime animation stuff such as: Animation Rigging | Animation Rigging | 1.3.0

Hope that helps!

Thanks. I did discover animator.StartRecording, animator.StopRecording, and animator.playback, which is almost exactly what I want. The only issue I have is that it seems it has to record in real-time. I really need to cache the data as fast as possible. I tried turning up the frame time to cache faster than real time, but then the playback get weird.