# Recoil Animation

## How does it work?

The recoil is generated in [<mark style="color:purple;">URecoilAnimationComponent</mark>](https://hitmans-store.gitbook.io/pras-documentation/types#urecoilanimationcomponent), which uses <mark style="color:purple;">VectorCurve</mark> assets and [<mark style="color:purple;">Recoil Stored Data Assets</mark>](https://hitmans-store.gitbook.io/pras-documentation/types#ustoreddata) to generate recoil.

The idea behind the whole system is based on the interpolation between the 0 and Target Values based on the custom curve:

> RecoilValue = Lerp(0f, TargetValue, CurveValue)

CurveValue is not clamped in **\[0;1]** range, which gives us the possibility to achieve that bouncy and springy motion without using spring interpolation. This solution is frame-rate independent, and much more intuitive and easier to use rather than simple interpolation.

## How do curves work?

<figure><img src="https://2362259812-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gr144sikDQaVKyIhHfL%2Fuploads%2FMa7BOnlq6uHUZyR7Ao0e%2Fimage.png?alt=media&#x26;token=c928291a-10d1-4b99-9ada-68f7e72fc029" alt="" width="416"><figcaption><p>So many curves</p></figcaption></figure>

You probably noticed that there're quite a lot of slots for curves - you only need to use the Single and Auto slots!

{% hint style="success" %}
**Tip:** Rest slots are legacy slots, which are no longer required, and exist for backward compatibility.
{% endhint %}

Let's take a closer look at the curves:

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

<figure><img src="https://2362259812-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gr144sikDQaVKyIhHfL%2Fuploads%2FsbdY6lpNJbipJMj0vK56%2Fimage.png?alt=media&#x26;token=f277f9ea-b4f3-4f75-b692-31dabf77aac9" alt="" width="563"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Auto" %}

<figure><img src="https://2362259812-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gr144sikDQaVKyIhHfL%2Fuploads%2FWqlMKoiihpkUTG52u2TU%2Fimage.png?alt=media&#x26;token=e6815eb9-3b20-4462-8d30-a301a5f132ad" alt="" width="563"><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

As you can see the Auto curves are very close to zero at some point. This point is the time delay between shots.

**Example:** let's say the weapon fire rate is 600 RPM, this means the delay between shots is `60 / 600 = 0.1s`. This means that Auto curves should be very close to zero around 0.1s to achieve smooth results.

Another important aspect is that **all** curves start and end with **zero.**
