Blending Gameplay and Sequencer Animation

Illustrates how you can blend animation smoothly from gameplay into a Level Sequence based animation.

Choose your operating system:

Windows

macOS

Linux

When creating your cinematic sequences, you may want to blend existing gameplay animation with animation contained inside your Level Sequence. For example, a playable character walks up to a door during gameplay and you want Sequencer to animate the character and open the door. Or a player is controlling their character in a third person shooter and comes around a blind corner and you want to blend in a cinematic death sequence. By using a combination of Sequencer, Blueprint, and an Animation Blueprint you can blend whatever gameplay pose your character is in with a Slot animation defined by Sequencer.

In this example, we take whatever gameplay pose the character is in when entering a trigger volume and blend it with a death animation inside Sequencer.

1 - Sequence Setup

In this step we set up our Level Sequence and add our playable character and animation we want to blend to.

For this how-to guide, we are using the Blueprint Third Person Template with Animation Starter Pack available for free from the Epic Marketplace.

AnimStarterPack.png

  1. Inside your project, delete the ThirdPersonCharacter from the level and add the Ue4ASP_Character , setting Auto Possess Player to Player 0 .

    GameBlend_01.png

    Optionally, you can disable the capsule component from being displayed by selecting the capsule component then checking the Hidden in Game option.

    GameBlend_01b.png

  2. From the main toolbar, click the Cinematics button then select Add Level Sequence and save it with any name.

    GameBlend_02.png

  3. In your Level Sequence, add the Ue4ASP_Character and an Animation Track with Death_3 assigned as the animation.

    GameBlend_03.png

  4. Right-click on the animation in the keyframe window then under properties, change When Finished to Keep State .

    GameBlend_03b.png

    This will enable us to preserve the animation state when the Level Sequence is over. Also, take note of the Slot Name property highlighted below.

    GameBlend_03c.png

    When an Animation Blueprint is controlling a Skeletal Mesh, Sequencer plays back animations on slots within that Blueprint and is controllable through the Slot Name property. An Animation Blueprint can then Blend between a slot Animation and whatever game logic driven animation your character may happen to be in.

In the next step, we set up our Animation Blueprint and Character Blueprint so that we can blend from our gameplay animation into our death animation we created in this step.

2 - Animation and Character Blueprint Setup

In this step we will set up our Animation Blueprint so that we can take our gameplay pose and blend to a Slot animation defined by our Level Sequence.

  1. In the Content Browser , locate and open the UE4ASP_HeroTPP_AnimBlueprint then double-click on the AnimGraph in the My Blueprint window.

    GameBlend_04.png

  2. In the AnimGraph off the existing Locomotion State Machine, create a New Save Cached Pose and call it lococache .

    GameBlend_05.png

  3. Use the lococache twice and connect one to the A pin of a Blend node which feeds the Final Animation Pose .

    GameBlend_06.png

  4. Off the other lococache , use a Slot node and connect it to the B pin of the Blend , then right-click on Alpha and Promote to Variable and call it Blend Interp .

    GameBlend_07.png

  5. In the Content Browser open the Ue4ASP_Character Blueprint and replace the Crouching section with the graph below.

    GameBlend_08.png

    Above we are replacing the InputAction Crouch node with the C keyboard event and a Flip Flop node to toggle our crouching states.

    This Blueprint was originally created for another project which included an input binding for crouch which our template project does not have. By replacing the InputAction Crouch with a standard C keyboard event, we will eliminate the Blueprint warning messages as well as enable us to press the C key to toggle between crouching and non-crouching states.

  6. Create a new Float variable called DefaultSlotInterp and set Instance Editable and Expose to Cinematics to True .

    GameBlend_09.png

    We will use this variable inside Sequencer to blend and pass the value over to the Animation Blueprint variable Blend Interp which handles the actual blend.

  7. Create a new function called SetDefaultSlotInterp and add an Input called Interp of the Float type in the Details panel.

    GameBlend_10.png

    By creating a function called Set (Property Value Name) we have created a Proxy function that will be called by Sequencer whenever the associated property value changes. This function is only called when the propery value changes and is more efficent than using Event Tick or a Custom Event and Timeline to reflect changes in the DefaultSlotInterp property value.

  8. From the Components window, drag in the Mesh and use Get Anim Instance and Cast to UE4ASP_HeroTPP_AnimBlueprint .

    GameBlend_11.png

  9. Off As UE4ASP Hero TPP Anim Blueprint , use Set Blend Interp and pass in the Interp value to the Blend Interp in.

    GameBlend_12.png

    Whenever our DefaultSlotInterp value is changed through Sequencer, the SetDefaultSlotInterp proxy function is called and the float value is passed through to the Animation Blueprint's Blend Interp value which affects the blending of our poses.

In the next step we will add the Default Slot Interp property to our Level Sequence so that we can control the Blend Interp in our Animation Blueprint. We'll also add a Trigger Box to the level so that we can activite our Level Sequence and play it when the player enters the Trigger Box volume.

3 - Using Cinematic Exposed Variables

Here we add the float variable Default Slot Interp which is feeding the interp in our Animation Blueprint, determining when we blend from a gameplay pose to our Slot animation. We also add a Trigger Box to the level that we will use in the next step to allow the player to trigger the playback of our Level Sequence when they enter its volume.

  1. Inside your Level Sequence for the Ue4ASP_Character , click the Track button and assign the new Default Slot Interp property.

    GameBlend_13.png

  2. Scub the timeline ahead to frame 25 (or whichever frame you prefer) and add a key for Default Slot Interp with a value of 1.0 .

    GameBlend_14.png

  3. From the Place Actors panel in the main level editor, drag a Triggerbox into the level and resize and place where desired.

    GameBlend_15.png

    You can optionally set Actor Hidden In Game to false if you want to be able to see the trigger volume during playback.

In the next and final step of this guide, we set up the Level Blueprint to playback our Level Sequence when we enter the Trigger Box's volume.

4 - Triggering the Sequence Playback and Blend

In the final step before we can test out our setup, we use the Level Blueprint to activate our Level Sequence when the player enters the Trigger Box. When our Sequence starts, the property DefaultSlotInterp that is exposed to cinematics is changed which starts the process of updating our interp values. This tells our Animation Blueprint to start blending from gameplay animation to our Slot Animation.

  1. With the Triggerbox selected, from the main toolbar, click the Blueprints button then Open Level Blueprint .

    GameBlend_16.png

  2. Right-click in the graph then under Collision for the Trigger Box select Add On Actor Begin Overlap .

    GameBlend_17.png

  3. Return to the level viewport and select your Level Sequence, then in the Level Blueprint right-click and add a reference to your Level Sequence.

    GameBlend_18.png

  4. Off your Level Sequence, use Get Sequence Player then off it use the Play node and connect as shown.

    GameBlend_19.png

  5. Compile and Save , then click Play to play in the editor.

End Result

When our character enters the trigger volume, regardless of their current animation state, we start to blend from our gameplay pose into our death pose defined by Sequencer.

We could take this a step further by adding a camera to our Sequence and improve the blending by shifting the point in which the death animation starts in our Sequence.

In the example above, the player can walk, run, crouch walk, or jump into the trigger and each case they will blend into the death animation when entering the trigger volume.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss