# Recoil Pattern

## Properties

**Recoil Pattern** represents the controller recoil, which is added to the character and camera rotation. This type of recoil is controller by the player, so it has a practical purpose.

The recoil is generated in a standalone component, make sure to add it to your character:

<figure><img src="https://784345943-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxcUmJ78NSw1bSUlSO9oP%2Fuploads%2FweAKlKOzve4IrUVn0TbG%2Fimage.png?alt=media&#x26;token=a1b66345-68fc-418d-b645-c5d423829d8e" alt="" width="383"><figcaption><p>Recoil Pattern.</p></figcaption></figure>

**Recoil Settings** define the actual recoil properties, such as damping, randomized targets for vertical/horizontal recoil, etc.

**Delta Look Input Property** represents the delta input value, which is related to the User Input Controller component we added previously in [components](https://kinemation.gitbook.io/scriptable-animation-system/workflow/components "mention")section.

Let's take a look at the **Recoil Settings**:

<figure><img src="https://784345943-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxcUmJ78NSw1bSUlSO9oP%2Fuploads%2F78AwJsy7mqxzQNXFLFN5%2Fimage.png?alt=media&#x26;token=78e51a25-368c-45ac-addb-3f8658c007ac" alt="" width="368"><figcaption><p>Recoil Pattern settings.</p></figcaption></figure>

**Horizontal/Vertical Recoil** defines the randomized range.

**Horizontal/Vertical Smoothing** define the interpolation speed.

**Damping** defines how fast we should return to the initial screen position.

## Integration

To add the recoil to your controller, make sure to grab a reference to the **Recoil Pattern** component first.

Then, make sure to access the component and add the recoil to the player inut:

```csharp
if (_recoilPattern != null)
{
    _playerInput.y += deltaMouseY;
    _playerInput += _recoilPattern.GetRecoilDelta();
}
```

Then, call the *Init* method when a gun is equipped:

```csharp
_recoilPattern.Init(recoilPatternSettings);
```

Finally, call the *OnFireStart* and *OnFireStop* methods:

```csharp
_recoilPattern.OnFireStart(); // Call every shot.
```

```csharp
_recoilPattern.OnFireEnd(); // Call when firing is cancelled.
```
