I am working on a project with a rather unique combat system and am running into a wall when it comes to working with animations.
Specifically, I need to be able to play any animationclip at any time within the clip. This would be similar to using AnimationCurve.Evaluate, but for an entire animation clip, rather than a single curve. I looked at AnimationClip.SampleAnimation, but this didn’t seem to work. As a general example, my use case looks along the lines of:
AnimationClip clip;
float time = 0f;
void Update(){
time += Time.deltaTime;
clip.Sample(time); //This is where I'd like to sample the animation
}
Obviously, the real script is far more elaborate and involves clips playing forward, backward, stopping, or jumping to arbitrary frames. This example script is essentially just the default behaviour of an animator, playing the clip immediately.
Another thing to note is that there may be a large number of animations involved, and adding them all to an animator controller is rather impractical. As such I’d like to stay as far away from mecanim and the animator controller or playables for these as possible. I’ve had mixed results with the legacy animation component, but would also rather avoid that due to the potential for it to be removed (the documentation states that it is only for backward compatibility).
All in all, it appears that much of the API is based on playing clips or blending between them, but I instead wish to sample the animations manually. I don’t need crossfading, layers, states, or blending for this, just simple sampling as you would with an individual curve.
I know this is probably an odd request, but if anyone knows how to do this I would greatly appreciate any pointers in the right direction.
Thanks!