Hello,
I have two animations on a 6-legged dinosaur, between which I want to transition (walk, run)
However, walk is played at 0.5 speed, run is played at 1.0 speed. Transition lasts 0.25 seconds
When I transition, say, from “walk” to “run”, the Run animation is not lined-up with the walk animation.
This means if the right foot was in front during walkcyle, in runcyle the same foot would be at the back.
Is there a way to “pre-match” the Running animation first (find the time where bones positions match best the ones of Walk), and then transition?
Thanks!
Solved it myself: Do cycle offset of the state into which we transitioning, using my personal-animator-parameter (float).
We change that parameter with StateMachineBehavior. The behavior must also hold a name of the state into which we will be transitioning, and during gameplay we can check if the GetNextAnimatorStateInfo().name
corresponds to the held name.
if it matches, then we will offset the future animation as needed. This might require behavior to contain a list with few Vector2 values.
For example, [‘0.2, 0.2’, ‘0.4, 0.8’, ‘1.0, 0.0’]
Here we see three Vector2, and can see if current state is at normalized time 0.2, then the animation into which we are transitioning should be at 0.2, etc.
In order to ideed bring it to 0.2, we will use the previously mentioned offset-parameter in our Animator.
For any values in-between (like 0.3) we will use linear interpolation between two closest vector2s.