5. Animation Blueprint - Idle and Walk States

Here in this step, we'll create the logic for Idle and Walking states for our character in our Animation Blueprint.


In this section, we will set up the Animation Blueprint that will determine what animations to play based on the actions that are taken in game by the player. We will then set up a State Machine and create an Idle and Walk state and set up the transition between each state.

For more information on Animation Blueprints, refer to the Animation Blueprints documentation.

The steps below will show you how to set up the Animation Blueprint:

  1. Locate and open your MyAnimationBlueprint asset.

  2. In the MyBlueprint window, create 4 Bool variables (IsJumping, IsCrouching, IsJogging, and IsProne).

  3. Create 2 Float variables (Speed and Direction).


  4. In the MyBlueprint window, Double-click the EventGraph to open the Event Graph tab.

  5. On the Event Graph, recreate the setup below then click the Compile button.

    Click image for full view.

    In the graph above, we are getting the direction of the player character and their speed and assigning them to variables that will be used inside the Animation Blueprint. We are also getting variables from our MyCharacter Blueprint (by dragging off the Try Get Pawn Owner node and Casting to our Character Blueprint) which corresponds to actions taken by the player. Those variables are then passed to variables inside the Animation Blueprint that will determine when to transition to/from Animation States.

  6. Click the Anim Graph tab, Right-click in the graph and search for and add a new State Machine.


  7. Give the State Machine a name, then connect it to the Final Animation Pose node.


  8. Double-click on the State Machine to open it.

  9. In the Asset Browser window, search for Idle and drag the Idle_Rifle_Hip asset into the graph.


  10. Connect the Entry node to the Idle_Rifle_Hip node, then click Compile.


    You should see the character enter the idle position in the preview window after clicking compile.

  11. In the Asset Browser, search for the Walk_BS and drag it into the graph.


  12. Double-click on the Walk_BS, then from the MyBlueprint tab, hold Control and drag in the Speed and Direction variables.


    Connect as shown above. Here we are providing the Blend Space with values from our character.

  13. Close the Walk_BS tab, then on the State Machine graph, create a Transition from Idle_Rifle_Hip to Walk_BS.


  14. Create a Transition from Walk_BS to Idle_Rifle_Hip, then Double-click on the Transition Rule for Idle_Rifle_Hip to Walk_BS.


    The Transition Rule determines when the State Machine can move between Animation States.

  15. Inside the Transition Rule, recreate the graph shown below.


    In the script above, we are checking to make sure the player character is currently not in the air (either from falling or jumping) and that their current speed is greater than 160, if so we will allow the transition from Idle to Walk to occur.

  16. Return to the State Machine graph and open the Transition Rule for Walk_BS to Idle_Rifle_Hip.

  17. Inside the Transition Rule, recreate the graph shown below.


    Here we are allowing the transition to occur if the character's speed is less than 160.

  18. Compile and Save the Animation Blueprint.

Select Skin

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback