Creating a Blend Space

Blend Spaces are special assets which can be sampled in AnimGraphs that allow for blending of animations based on the values of two inputs. Simple blending between two animations based on a single input can be performed using one of the standard Blend Nodes available in Animation Blueprints. Blend Spaces provide a means of doing more complex blending between multiple animations based on multiple values (currently limited to two).

In this How-to, we use a Blend Space to blend between walking and jogging animations based on the character's movement speed and movement direction.

For this guide we are using the Blueprint Third Person Template project and have added the Animation Starter Pack to the project:

AnimationAssetPack.png

You can download the Animation Starter Pack for free through the Marketplace from the Epic Launcher.

Steps

  1. In your project in the Content/ThirdPersonBP/Blueprints folder, open the ThirdPersonGameMode and set the Default Pawn Class to Ue4ASP_Character.

    BlendSpace1.png

    This will allow us to use the playable character that was created along with the Animation Starter Pack project.

  2. In the Level, select the ThirdPersonCharacter and delete it from the level.

    BlendSpace2.png

    We need to delete this character from the level in order to spawn in as the character from the previous step.

  3. In the Content/AnimStarterPack/UE4_Mannequin/Mesh folder, Right-click on the UE4_Mannequin and under Create, select Blend Space.

    BlendSpace3.png

    Blend Space assets need a Skeleton asset to reference, here we are using a shortcut to create a Blend Space from this Skeleton asset.

  4. In the Parameters section, apply the values below then press the Apply Parameter Changes button.

    BlendSpace4.png

    • Set the X Axis Label to Direction

    • Set the X Axis Range to -180 - 180

    • Set the Y Axis Label to Speed

    • Set the Y Axis Range to 150 - 260

    This Blend Space using the parameters Direction and Speed to determine which pose we should be using or blending to or from.

  5. In the Asset Browser, drag the Walk_Fwd_Rifle_Ironsights animation to the center-bottom position on the grid.

    BlendSpace5.png

    Placing this animation here indicates that when our Speed is 150 and are direction is not left or right, we should be walking forward with our rifle up at ironsights level.

  6. Drag the Walk_Lt_Rifle_Ironsights animation to location 1 and Walk_Rt_Rifle_Ironsights animation to location 2 below.

    BlendSpace6.png

    Here we place the animations to use when moving left or right and our speed is 150.

  7. Drag the Walk_Bwd_Rifle_Ironsights animation to locations 1 and 2 below.

    BlendSpace7.png

    Here we place the animation to use when moving backward and our speed it 150.

  8. From the Asset Browser, drag the Jog_Fwd_Rifle animation to the top-center position on the grid.

    BlendSpace8.png

    This allows us to use a different animation when our speed is at max 270 and we are not moving left or right, we are jogging forward.

  9. Drag the Jog_Lt_Rifle animation to location 1 and Jog_Rt_Rifle animation to location 2 below.

    BlendSpace9.png

  10. Drag the Jog_Bwd_Rifle animation to locations 1 and 2 below.

    BlendSpace10.png

  11. In the Content/AnimStarterPack folder, open the UE4ASP_HeroTPP_AnimBlueprint then in the My Blueprint panel, Double-click the Locomotion graph.

    BlendSpace11.png

  12. Double-click the Jog State to open its graph.

    BlendSpace12.png

    This State Machine already has a Jog State and in it, a Blend Space for different Jogging motions.

  13. From the Asset Browser, drag the Walk_Jog_BS into the graph and replace the BS_Jog Blend Space as shown below.

    BlendSpace13.png

    The default Blend Space does not include Walking states which our Blend Space does, so let's replace it with ours!

  14. In the Content/AnimStarterPack folder, open the Ue4ASP_Character.

  15. Locate the section marked Crouch in the graph and replace the InputAction Crouch node with a C Key Event.

    BlendSpace14.png

    By default, the Animation Starter Pack has bindings created for crouch which we will replace with a normal C press (or whatever key you want to crouch with).

  16. Right-click in the graph and add a Left Shift Key Event, then drag the CharacterMovement into the graph from the Components tab.

    BlendSpace15.png

    When we press and hold the Left Shift button, that will toggle us from walking into a jog.

  17. Hold the B key and Left-click in the graph and create two Branch nodes, then drag in the Crouch Button Down variable and connect as shown below.

    BlendSpace16.png

    We need to check and make sure that we are not crouching while holding shift (as for this example, sprinting can only occur when not crouched).

  18. Drag off the CharacterMovement node and Set Max Walk Speed for both Branch nodes with the values 260 and 150 respectively.

    BlendSpace17.png

    We are changing our movement speed based on if Left Shift is held and will alter our character's movement speed in game.

  19. Right-click in the graph and add an Event Begin Play node and connect a CharacterMovement component to Set Max Walk Speed to 150.

    BlendSpace20.png

    To start the game, we need to update our character's default movement speed so they start out walking.

  20. Click the CapsuleComponent in the Components tab and in the Details panel, check the Hidden in Game option.

    BlendSpace18.png

    This will turn off the collision capsule debug display in game.

  21. Click the CharacterMovement component, then in the Details panel set the Max Walk Speed to 260.

    BlendSpace19.png

    Here we are capping the maximum movement speed to reflect what is in our Blend Space.

  22. Click Compile then click the Play in editor button from the Toolbar.

End Result

When playing in the Editor, using WASD to move around, the character will now walk by default and blend between walking animations when changing directions. While standing, pressing and holding Left Shift while using WASD will cause the character to blend from the walk/aim animation to a lowered/aim jog animation, essentially creating a sprint for the character. You can also press and hold C, to crouch walk using the Blend Space that was created as part of the Animation Starter Pack project, blending between crouch walking animations.