How to stop player moving while transitioning between animations with different root positions
I have two different animations and one ends like this:
And the other starts like this:
As you can see the root is at different places, and unlike the Y root transform, it is not possible to add an offset on XZ. This means the player moves forward in transition and ends up inside the wall (if you imagine the edge of the wall at the correct position in the first animation).
Is there a way to prevent this without modifying the animations themselves?
You may have to dig deep in to what the Animator offers, like I$$anonymous$$, RootPosition etc.
Answer by Tiernan98 · Apr 01, 2018 at 09:39 PM
I've come across checking if the animator is in transition using the "AnimatorTransitionInfo" class. I push the avatar back by a constant value each frame, but if anyone still knows a better solution let me know!
Answer by meat5000 · Apr 02, 2018 at 07:05 AM
If you are not interested in Animator scripting then the next option is to go back and modify the original animations to have matching positions. This is the very basis of Root Motion, to begin with. The next step is to go to the animation import and for each troublesome Action, play with the Root Transform Position. Baking, offsets etc. If you are unable to simply modify the Transform position then you may need to scan through the available Methods at the Animator : There are lots to choose from.
https://docs.unity3d.com/ScriptReference/Animator.html https://docs.unity3d.com/ScriptReference/Animator.SetIKPosition.html
Your answer
Follow this Question
Related Questions
animating in unity 0 Answers
Death animation for enemy 0 Answers
GetComponent().StopPlayback(); Does nothing? 0 Answers
Avatar Mask doesn't do anything 0 Answers
Animating Material, how to set material after animation? 0 Answers