Using root motion for a 180 degrees turn
In the previous recipe, we've added a stop animation for a better transition to the idle state. We can add even more animations to our movement to make it more accurate and responsive. An example of such animation is a 180-degree turn.
Getting ready
Use the same character as in the previous recipe. Add a 180-degree turn animation, starting with the Idle pose and ending with the Idle pose rotated by 180 degrees in the vertical axis. Name the animation 180Turn
for clarity. You can open the provided example Unity project and go to the Chapter 04 Character movement\Recipe 05 Using root motion for a 180 degrees turn
directory. You will find an Example.unity
scene there. Play the game and try to walk in the direction opposite to the one the character is facing (press the down arrow). You can find the Humanoid.fbx
asset in the Rigs
directory with all the required animations.
How to do it...
To make a 180-degree turn, follow these steps:
- Create four transitions...