> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinemation.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# 🔫Recoil Animation

> In this section you will learn about procedural recoil animations.

The recoil system in the framework consists of these 3 main components:

* Recoil Animation

* Recoil Pattern

* Camera Shake

In this chapter we will cover the procedural animations, and how to create that really nice and fluid recoil.

## Component

Make sure to add the RecoilAnimation component to your character. This component will generate that smooth recoil in realtime, which will be applied by the [Additive Layer](/scriptable-animation-system/fundamentals/animator-layers/additive-layer).

This component has 3 main methods:

```text theme={null}
public void Play(); // Fired a gun, call it every shot.
```

```text theme={null}
public void Stop(); // Call it when fire key is released.
```

```text theme={null}
// Call this when a gun is equipped.
void Init(RecoilAnimData data, float fireRate, FireMode newFireMode);
```

## Basic Properties

<img src="https://mintcdn.com/kinemation/IMbHDDWE_rjJU7jO/images/scriptable-animation-system/5680cdeb6b59aa1b5bed.png?fit=max&auto=format&n=IMbHDDWE_rjJU7jO&q=85&s=86b74036e2dd82e3befbcd1cc6b58e51" alt="" width={404} data-path="images/scriptable-animation-system/5680cdeb6b59aa1b5bed.png" />

This asset contains animation curves and values for the recoil solver:

<Tabs>
  <Tab title="Option">
    * **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:

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

    **Aim Rot** and **Aim Loc** define multipliers for each rotation and transaltion. Applied when aiming.
  </Tab>

  <Tab title="Option">
    **Smooth Rot/Loc** - defines interpolation speed for rotation and translation. Not applied if 0. **Extra Rot/Loc** - multipliers applied in auto/burst mode only.
  </Tab>

  <Tab title="Option">
    * 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.
  </Tab>

  <Tab title="Option">
    Hip Pivot Offset - weapon pivot offset when hip firing.

    Aim Pivot Offset - weapon pivot offset when aiming.

    Smooth Roll - if enabled, the sign of a random value for roll will change every shot.

    Play Rate - the speed of the recoil animation.

    Recoil Curves - normalized animation curves.
  </Tab>
</Tabs>

## Recoil Curves

There are 4 Vector curves in the data asset, where each Vector curve is designed to animate the rotation or translation when auto/single firing.

<Frame caption={"Example semi curves."}>
  <img src="https://mintcdn.com/kinemation/IMbHDDWE_rjJU7jO/images/scriptable-animation-system/2c80ec541183200005ea.png?fit=max&auto=format&n=IMbHDDWE_rjJU7jO&q=85&s=241fbe61405657ecf8bbdb29e66596e3" alt="" width={404} data-path="images/scriptable-animation-system/2c80ec541183200005ea.png" />
</Frame>

<Info>
  **Tip:** all curves must start and end with zero!
</Info>

Here's the difference between auto and semi curves:

<Tabs>
  <Tab title="Option">
    <img src="https://mintcdn.com/kinemation/IMbHDDWE_rjJU7jO/images/scriptable-animation-system/c53c54bb5f7ba19a1adb.png?fit=max&auto=format&n=IMbHDDWE_rjJU7jO&q=85&s=a026b4a195708e4b710535c05631d7c1" alt="" width={375} data-path="images/scriptable-animation-system/c53c54bb5f7ba19a1adb.png" />
  </Tab>

  <Tab title="Option">
    <img src="https://mintcdn.com/kinemation/IMbHDDWE_rjJU7jO/images/scriptable-animation-system/5a9cc386854c1c31be8d.png?fit=max&auto=format&n=IMbHDDWE_rjJU7jO&q=85&s=1e86a48d0afbc52e1642229e453a1473" alt="" width={375} data-path="images/scriptable-animation-system/5a9cc386854c1c31be8d.png" />
  </Tab>
</Tabs>

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.

<Tip>
  **Tip:** this is required for the auto solver to work properly. When 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.
</Tip>
