- Home /
Evaluating arbitrary frames of Mecanim animation
I'm making some dynamic adjustments to Mecanim animations via code. It's easy to read and overwrite values for bone transforms, rotations etc. in the current animation frame by using e.g. GetBoneTransform in LateUpdate().
However, it'd be useful for my blending code to be able to retrieve values from future frames of the animation - both of the current clip and clips associated with other states that I might transition to. So is there a way to retrieve, say, the position of the hips in frame 0 of the "idle" clip, or the location of the right leg after 0.5 seconds of the "run" animation? All the methods of the Animator class I could see seem to only relate to the current state :(
I've still hardly touched animation in my projects. Is it possible/plausible to fast forward the animation by half a second, make the adjustment, then rewind? This does sound rather ugly as a workaround.
Thanks for the comment and suggestion :) I did wonder about having a secondary "dummy" object that scrubs through the animation purely for the purpose of retrieving transform values of joints at different times, but it just seems a horrible hack!
I also wondered about whether I could pre-compute the values somehow in an editor script (since the Animator control is fixed, the animation values should be entirely deter$$anonymous$$istic), but I'm not convinced it's possible to play through an animation at design-time. Will keep on experimenting!
How about using this
http://docs.unity3d.com/ScriptReference/Animator.StartPlayback.html
Ok its vague. $$anonymous$$ultiplexing your animations is gonna end in ugliness. You can Play() a state of your choice, you can retrieve the next state basic info, you can get I$$anonymous$$ positions and rotation etc etc etc. If you have a ton and a half of free cycles to play with you can have a hidden character which you perform this on and retrieve the bone data from it ins$$anonymous$$d.
But yes, you can play an individual state at a particular frame-time. This is essentially what you need.
Useless, I know. Just wanted to make your QA feel less ignored :)