Skip to main content
‹ Back to Tutorials
Intermediate Unity

Unity Playmaker 2D Platformer - Play Animation Idle and Run

Oct 10, 2021
About this tutorial

In this Unity Playmaker 2D Platformer - Play Animation Idle and Run tutorial, I'll show how you can set up animations that change based on the X axis input in Playmaker. This will allow you to switch between run and idle animations easily. I'll set up 2 States for idle and run and we will switch b

Written Guide

With movement and sprite flipping already working, the next piece is making the character actually animate. This tutorial drives an idle and a walk animation from Playmaker using a two-state FSM and a single float comparison — no animator parameters, no transition graph, no code.

What you need first The character already moves left and right using Get Axis, which writes into a global float variable called X Move, and the sprite flips based on that value. Two animation clips exist and are already in the Animator: robot idle, which is just the head bobbing up and down, and robot move, a simple walk cycle. Knowing the exact clip names matters, because you'll be typing them into actions shortly.

Step 1 — Add a dedicated animation FSM Select the player and add a new FSM in Playmaker. Name it Player Animator. Giving animation its own FSM rather than bolting states onto the movement FSM keeps the two concerns separate — movement logic and animation state stay independently readable and independently debuggable.

Step 2 — Create the two states Rename the starting state to Idle and add a second state called Move. That's the entire state machine: the character is either standing still or walking, and everything else is the logic for deciding which.

Step 3 — Play the right clip in each state In the Idle state, add the Animator Play action. Set the game object to Owner and enter robot idle as the animation name. Copy that action, paste it into the Move state, and change the clip name to robot move. Each state now plays its clip on entry.

Step 4 — Detect movement from the Idle state Add a Float Compare action to Idle and point it at the X Move global variable, comparing against 0. When the player is holding a direction, X Move will be either greater or less than zero. Create a new event called Move and assign it to both the Less Than and Greater Than outputs — either direction means the character is walking. Add the transition and wire it to the Move state. Critically, check Every Frame on the Float Compare, otherwise it evaluates once on entry and the state never leaves.

Step 5 — Detect stopping from the Move state Add a Float Compare to the Move state as well, again comparing X Move against 0. This time do the opposite: leave Less Than and Greater Than set to None and use the Equal output. Create an event called Idle, assign it to Equal, and transition back to the Idle state. Check Every Frame here too.

Step 6 — Understand the symmetry The two states mirror each other and it's worth stating plainly. Idle plays the idle clip and watches every frame for X Move to become non-zero, then jumps to Move. Move plays the walk clip and watches every frame for X Move to hit zero, then jumps back to Idle. Because the comparison reads the same variable that drives movement, the animation can never disagree with what the character is actually doing.

Step 7 — Test Press play. The character starts in idle with the head bobbing. Press a movement key and it switches instantly to the walk cycle. Release and it returns to idle. Adding more states later — jump, crouch, attack — follows the same pattern: a state that plays a clip, plus a condition that decides when to leave it.

Unity tools by Bliz Studio
Built for our own games — now on the Asset Store

Multi Tag — unlimited hierarchical tags for any GameObject. Hierarchy Pro — style your whole hierarchy with rules. Made by a Unity dev, for Unity devs.

Explore our Unity assets →