# Mantle

### Introduction

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

<figure><img src="/files/Ni6JLX0XhCMScLGcB1VZ" alt="" width="375"><figcaption></figcaption></figure>

### Project Setup

For this tutorial, I will be using the `ThirdPerson template`. I recommend you do the same to make it easier to follow. However, if you prefer, you can certainly work from an existing project or even start from scratch. Once the project is open, if you are not yet familiar with the installation and configuration of the plugin, I suggest following [this quick tutorial](/getting-started/getting-started/installation/installation-in-a-blueprint-project.md) beforehand.

#### Installation Check&#x20;

If you have followed the installation correctly, your character class should normally inherit from `AMS_Character`, and your `CharacterMovementComponent` should inherit from `AMS_CharacterMovementComponent`. Also, make sure to use the `OnMoveOnGround` method to move. If everything is in place, then that's perfect!

<figure><img src="/files/wwOiAmQqXd1HopxE2oho" alt=""><figcaption></figcaption></figure>

#### Adding the Motion Warping Plugin

The plugin is designed to be as unrestrictive as possible, allowing everyone to use the method they prefer. For our tutorial, we will use the `Motion Warping plugin`, as it provides smooth and natural transitions, dynamically adapts to surfaces, and reduces the need for specific animations. This makes integration easier and enhances gameplay immersion.

In your project, go to `Edit -> Plugins` to open the plugin browser. Once the plugins window is open, use the search bar to find `Motion Warping`. **Check the box** to activate the plugin, then **restart the editor** to apply the changes.

<figure><img src="/files/JS03Wpw0nGJ2gCcmQYWw" alt=""><figcaption></figcaption></figure>

### Importing Animations

To create a visually pleasing example, we will download high-quality animations from **GASP** demo provided by Epic Games. These animations, created by professionals, are available for free. Isn't that great?

Migrate the animation montage **AM\_M\_Neutral\_Traversal\_Climb\_Start\_2\_5\_stand\_F\_Rfoot** to your project.

<div data-full-width="true"><figure><img src="/files/fo1GINFalbFXGIV3D5No" alt="" width="213"><figcaption></figcaption></figure></div>

If you’re not sure how to migrate elements from GASP to your project yet, I recommend checking out [this tutorial](/knowledgebase/tutorials/asset-export-tutorials/export-gasp-animations.md). It’s really simple and quick to do, you’ll see!

If everything is good, you should have a folder named `UEFN_Mannequin` added to your project with  the animation montage you selected.

<figure><img src="/files/7IhaJvkFWnohYZEYFCJD" alt=""><figcaption></figcaption></figure>

### Mantle Detection Setup

To start, **you can go to the Details tab of the character and access the Debug Settings section to display the traces**, if you wish. This will allow you to better observe the behavior of the detection in case of any issues.

<figure><img src="/files/ykqGUn4OqkTl2V7p1h6o" alt=""><figcaption></figcaption></figure>

Next, to configure the mantling detection, **go to the Details tab of the CharacterMovementComponent**. The search bar will help you quickly access the section dedicated to mantling. In this section, you will find the `MantleDetectionTrace structure`, which includes several sub-structures that allow you to adjust the detection of walls and ledges, as well as the necessary available space.

<figure><img src="/files/ZhkU2HZkwmwI3X7hS2Pv" alt=""><figcaption></figcaption></figure>

You can adjust the distance by setting a fixed value called `Base Distance`. If you wish, you can then dynamically modify this distance based on the speed and height of the capsule using the `influence factors`. You also have the option to choose whether these influences apply only when you are on the ground, which is often the case.

{% hint style="info" %}
Here’s an example where I set the `MaxVelocityInfluenceFactor` value of `WallDetectionForwardDistance` to `200`.
{% endhint %}

<figure><img src="/files/Hvu2NcZ6Ah7nSlLaUdMT" alt=""><figcaption></figcaption></figure>

In this example, given that we are taking a simple approach with few animations, we will use static detection. However, we will make use of the `influence factors` to adjust the detection based on whether the character is on the ground or in the ai&#x72;**. Refer to the image below to configure the detection using the same settings as shown.**

<figure><img src="/files/pe3Npvqtcoo2f3ZlbN5Z" alt=""><figcaption></figcaption></figure>

### Mantling

To perform a mantle, simply call the `StartMantle` method to make the character climb on the next update.

<figure><img src="/files/2XdHh6Qn0poMBJNipo74" alt=""><figcaption></figcaption></figure>

If the checks in `CanMantle` and the detection are valid, the method will then trigger the `OnMantleStarted` event after executing all the necessary logic. We will use this event to trigger our animations as well as perform other actions. **To do this, go to the Details tab of the CharacterMovementComponent and select the event to add it to the event graph**.

<figure><img src="/files/vyNa3kpi8RctuQKP085j" alt=""><figcaption></figcaption></figure>

We will use the `PlayMontage` function of the `SkeletalMesh` to play the animation montage `AM_M_Neutral_Traversal_Climb_Start_2_5_stand_F_Rfoot`. This will allow us to handle the necessary events to stop the mantle at the right moment.

<div><figure><img src="/files/OdjQkFOGOUmkPiIHC6yW" alt="" width="375"><figcaption></figcaption></figure> <figure><img src="/files/Ae3GMWPc8aPJy7ySpKK7" alt="" width="375"><figcaption></figcaption></figure></div>

If you test the mantle near a wall, the animation should play as expected. You'll notice that, for now, it's the animation that controls the character's movement. In our case, what **we want is to control the movement until the edge, and then let the animation handle the rest of the movement, but only once the character is properly adjusted.**

<figure><img src="/files/QFBbmiilA9TA5CRxpZsp" alt=""><figcaption></figcaption></figure>

To do this, we will use motion warping. The GASP animation montage already includes the necessary `Animation Notifications`. Set the `WarpPointAnimProvider` to `static` and adjust the `Z axis` (I set it to `260`).

{% hint style="warning" %}
If you're using UEFN mannequin or another that includes the `Attach bone`, you can skip this step. Just make sure the `WarpPointAnimBoneName` matches your bone's name.&#x20;
{% endhint %}

<figure><img src="/files/cu5z3jhLlIyHHzOjdRv0" alt=""><figcaption></figcaption></figure>

Next, **create a method in your character's Blueprint to generate the warp target that will be used by your anim montage**. In my example, I named it `CreateMantleWarpTargets` so that I can easily add other warp targets related to the mantle if needed. Add an input parameter of type `MantleCheck` to the function, which contains all the relevant information sent by the trace. With this data, you'll be able to get the position and rotation of the `FrontLedge` and use them to define your warp target.

<div><figure><img src="/files/kHgq9TDquO9DZKhUMFgP" alt="" width="375"><figcaption></figcaption></figure> <figure><img src="/files/jhlzaTRSPWAWQML8sHcS" alt="" width="375"><figcaption></figcaption></figure></div>

Then, call the method you just created in the `OnMantleStarted` event, right before playing your anim montage.

<figure><img src="/files/Y0qQSTIYGz3g6VBF6vGN" alt=""><figcaption></figcaption></figure>

**Great, the mantle system is now functional** and adapts perfectly to different wall heights!

<figure><img src="/files/4HZRMv825IBcUJh8muM0" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.spabastudio.com/knowledgebase/tutorials/blueprint-tutorials/manting/mantle.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
