Language:
Page Info
Skill Level:
Engine Version:

5. Animation Blueprint - Idle and Walk States

Choose your OS:

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).

    AnimBP_1.png

  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.

    AnimBP_AnimGraph2.png

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

    AnimBP_AnimGraph3.png

  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.

    AnimBP_AnimGraph4.png

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

    AnimBP_AnimGraph5.png

    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.

    AnimBP_Walk1.png

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

    AnimBP_Walk2.png

    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.

    AnimBP_Walk3.png

  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.

    AnimBP_Walk4.png

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

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

    AnimBP_Walk5.png

    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.

    AnimBP_Walk6.png

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

  18. Compile and Save the Animation Blueprint.