Simple Player Turn Animations

Objective: When the Left Shift key is held with a directional key the player will play a turning animation in that direction.

The first thing we need to do is create an animation for each of the different states our Player can be in:

  1. Idle animation for a starting and ending point for the animation.
  2. Left and Right turn animations.
  3. Return animations to return the Player to the Idle animation from the turn animations.

Now we can plan out how the animating is going to work from the Unity Animator Window:

The Empty state is our Idle animation, from there the player will turn left or right. Once the Player turns left or right the player will be able to stay in the turned state or leave it and enter the return state leading back to the Idle state.

We can use Boolean Parameters to decide when the player should enter each state:

Assign the conditions for the transitions for each of the states:

Idle to Turn:

Turn to Return:

Return to Idle:

Repeat for the other side and open up the Player script for the code.

We need to access the parameters from the Animator to be able to change them:

Now to set the Booleans we can use:


There will be three conditions that need to be met for the player to enter the turn animation:

  1. The left Shift key needs to be held down.
  2. A or Left Arrow key needs to be held down
  3. The player must have fuel left

If any of these conditions are false the Player won't turn or will leave the turn:

Repeat the same process for the Right side and make sure to call them under Update:

Learning to become a unity game developer