# Recoil Layer

## Basics

This layer is responsible for applying procedural recoil.

<figure><img src="https://3983499731-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxsGuM7QMKoTm8rnHX3cO%2Fuploads%2FZboxn9f31Hh2UDRHRaem%2Fimage.png?alt=media&#x26;token=1eb6ef3c-aec1-448b-a9ad-bc5740a499d2" alt="" width="335"><figcaption></figcaption></figure>

You don't have to set up anything in the layer itself, instead, we will prepare the Recoil Data Asset for your weapon.

Create a new Recoil Data Asset by right-clicking in any folder <mark style="background-color:blue;">**Create -> FPS Animator -> RecoilAnimData.**</mark>

This is how the Recoil Asset looks like:

<figure><img src="https://lh5.googleusercontent.com/FESAQvKG8bT5EseXc6SuJf6wCvTQbCxxu-qLtNVsgsw6KKIik-vwEDXoCCnnLh3VZlafrAfIM-KtvNKFiJqNvBlkrHU3D-YYvpAPCzNUHfE0zCQSRwzk5Xl8JlAoRbQZag6ZCt5H63heyvCOMBEJdsE" alt="" width="375"><figcaption><p>A74M_RecoilData from the demo files</p></figcaption></figure>

This asset contains animation curves and values for the recoil solver. Let's figure out how the curves work and how to prepare them.

## Recoil curves

There're recoil curves for each translation and rotation axis, 6 curves in total:

<figure><img src="https://3983499731-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxsGuM7QMKoTm8rnHX3cO%2Fuploads%2Ft5cLuiYtP4On4wFdYL1L%2Fimage.png?alt=media&#x26;token=99a14c78-0be6-4fff-90a0-ab358c3efdca" alt="" width="362"><figcaption></figcaption></figure>

{% hint style="info" %}
**Tip:** all curves must start and end with **zero**!
{% endhint %}

Here's the difference between auto and semi curves:

{% tabs %}
{% tab title="Semi" %}

<figure><img src="https://3983499731-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxsGuM7QMKoTm8rnHX3cO%2Fuploads%2F3ooNbV3opf5tah4FwVyN%2Fimage.png?alt=media&#x26;token=034d831a-60b4-4b1b-ad10-0d1b7bbcf87d" alt=""><figcaption><p>Semi curve</p></figcaption></figure>
{% endtab %}

{% tab title="Auto" %}

<figure><img src="broken-reference" alt=""><figcaption><p>Auto curve</p></figcaption></figure>
{% endtab %}
{% endtabs %}

Curves are almost identical, the only difference is that Auto curve value is very close to zero at some point - this point is the delay between shots.

> **Example:** let's say our fire rate is 600 RPM, then the delay between shots is 0.1s. This means, that all auto curves must be close to **0** at 0.1s time.

<details>

<summary>Why is that?</summary>

This is required for the auto solver to work properly. Whne auto/burst mode is enbaled, the curve length is set to the fire delay (see our example above). So, the length of the auto or burst curve gets cropped to the fire delay between shots.

</details>

## Recoil data

Let's break down some properties in **Recoil Anim Data** asset:

#### Rotation Targets

* Pitch - max and min values for the pitch (up) rotation
* Roll - max and min values for the roll rotation.
* Yaw - max and min values for the yaw (right) rotation.

Roll and Yaw components are Vector4. That's because of the way random values are calculated:

<figure><img src="https://lh4.googleusercontent.com/r6Ehg2JrQYbL3BqL9FSCl-pHcU4J2MImVg-E3LrftSHCOLIXbwwTPxGGWo6VewFYFlJHoBl9bFc53h8CZJVyTJOamoWeU79Dbfra8NtAq9VkdUCs2lKpSfbJIADyjV3BzqPcmMFttgxeEnEyCn3dnGA" alt="" width="375"><figcaption></figcaption></figure>

Minimum value for Roll and Yaw is a random value in **\[X;Y]** range, while maximum value is in **\[Z;W]** range.

#### Aiming Multipliers

Aim Rot and Aim Loc define multipliers for each rotation and transaltion. Applied when aiming.

#### Auto/Bursts Settings

* Smooth Rot/Loc - defines interpolation speed for rotation and translation. Not applied if 0.
* Extra Rot/Loc - multipliers applied in auto/burst mode only.

#### Noise Layer

* Noise X/Y - max and min values for position offsets along X and Y axes (right and up movement).
* Noise Accel - acceleration speed.
* Noise Damp - damping speed.
* Noise Scalar - aiming multipler.

#### Pushback Layer

Applied on the first shot of the auto or burst fire mode.

* Push Amount - maximum value of the pushback.
* Push Accel - acceleration speed.
* Push Damp - damping speed.

#### Misc

* Smooth Roll - if enabled, the sign of a random value for roll will change every shot.
* Play Rate - the speed of the recoil animation.


---

# 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://kinemation.gitbook.io/fps-animation-framework/fundamentals/animation-layers/recoil-layer.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.
