V.3.0.0

Mantling To Crouching

Explore how to create a Mantle To Crouch system for your Unreal Engine 5 game.

Introduction

In this tutorial, we will explore how to create a Mantle To Crouch system for your Unreal Engine 5 game. We will see how to enable your character to perform mantling movements on various surfaces and crouching when necessary.

alt text

Project Setup

For this tutorial, I will use the project from the basic mantle tutorial. I recommend following this same approach to make it easier to understand. However, if you are already familiar with the plugin, you can certainly work from your own project and adapt the tutorial accordingly.

Importing Animations

We will download 2 additional animations from GASP project to have a visually pleasing crouch and the transition from mantle to crouch.

Migrate the animations M_Neutral_Crouch_Idle_Loop and M_Neutral_Crouch_Loop_F to your project.

If you’re not sure how to migrate elements from GASP to your project yet, I recommend checking out this tutorial. It’s really simple and quick to do, you’ll see!

Crouching

We will now add the crouch feature, which will allow the character to automatically crouch when climbing an obstacle with a restricted surface.

Blueprint Logic

I have enabled the CameraLag on the SpringArmComponent, but this is optional. Next, in the Character Details tab, set CanCrouch to true to allow the character to crouch. Also, adjust the crouched walk speed and the capsule height according to your preferences.

alt text

Animation Blueprint

Next, go to the Main State Anim Graph of your character's animation blueprint:

  • A) Add a State Alias by right-clicking to facilitate managing transitions between states, and rename it to To Crouching.

  • B) Then add a reference to the Locomotion State in the Details panel of the State Alias.

alt text
alt text

We will now create a state to manage the character's crouch animation when he is stationary. We will rename it Crouch Idle, then go to the transition rule to ensure it is only called when the character is crouched.

alt text
alt text

Return to the Main States and double-click on the Crouch Idle state to add the animation to be played that you should have retargeted beforehand.

alt text
alt text

Next, create a second state to manage the character's crouch walking animation. We will rename it Crouch Walk, then go to the transition rule to ensure it is only called when the character is moving.

alt text
alt text

Then, double-click on the Crouch Walk state to add the animation to be played that you should have retargeted beforehand.

alt text
alt text

Add a transition rule to return to the Crouch Idle state when the character is no longer moving.

alt text
alt text

Add a State Alias and rename it To Locomotion to return to the standard locomotion state when the character is no longer crouching. Don’t forget to reference the Crouch Idle and Crouch Walk states using the Details panel of the state alias to allow the alias to listen for and manage transitions between these different states.

alt text

Great, the crouch is now functional ! If you’d like, you can check that everything is working well by using the Crouch and Uncrouch methods in your character's Blueprint.

Mantling to Crouching

To start, you can prepare the terrain by adding an extra block to your map to represent the area where the character will need to crouch in order to climb. In my example, I simply duplicated the SM_Cube4 block from the Third Person template and moved it by 330 on the Z-axis.

alt text
alt text

Normally, your character should already be able to crouch automatically by adjusting its capsule based on the surface. However, since the GASP project from which I got my animations doesn't include specific animations for transitioning from mantle to crouch, I'm using the same animation as for the standard mantle against a wall. Therefore, you'll notice that the character briefly stands up before transitioning back to a crouch position.

To fix that, we will modify the mantle Anim Montage by changing the Blend Out Condition type to Force Blend Out and adjusting the start of the notify that handles the blend out, placing it at the moment when the character starts to stand up. The problem is that now the Anim Montage will end earlier, which means we can no longer rely on it to handle the end of the mantle movement. Therefore, we will need to create a second warp target to manage this step instead.

alt text

Add a warp target in the same way as the one that handles the FrontLedge, then rename it FrontGround. You will also need to disable the WarpRotation.

alt text

Make sure to add it to your CreateMantleWarpTargets function.

alt text

If you want, you can make the character automatically stand up as soon as possible. To do this, you can use the OnMantleFinished event to call the Uncrouch method.

alt text
alt text

And there you have it, a smooth transition for our mantle!