Transitions

Transitions are simply how an object switches from one animation into the next. Going from an idle position to a walk is an example of transitioning. The process is very simple, but the logic can be a little tricky. The best way to think about it is to ask yourself, “Which animation or ‘state’ am I able to go into and out of?” Starting with an idle animation, your character would be able to transition into a walk state, but also stop moving and go back to his idle state.

In the Animator window, with the Player_Idle clip highlighted, right-click and select Make Transition. Drag the arrow indicator to the Player_Walk clip and release. Once we set the parameters and add the last lines of code to our PlayerController script, we can see ...

Get Learning 2D Game Development with Unity®: A Hands-On Guide to Game Creation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.