> For the complete documentation index, see [llms.txt](https://maystudios.gitbook.io/maysimplerecoil/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://maystudios.gitbook.io/maysimplerecoil/getting-started/markdown.md).

# Technical

## Overview:

<figure><img src="https://mermaid.ink/img/pako:eNqVVm1v2zYQ_iuEig4OoCTzsjixOhTwS-x6QJCsTjZs8T4w0skiSpEESSVxg_z3HUVGlhyvW_3F1N3z3N1DHk96jlKZQZREOZePaUG1JTfTlSDk_XtyKbOKA1kIZhnl7Cu1TArnM9X9WlNVBMQdmV3SzZKVisNnSCXjgfm3AxMyultF-xGrqIaAyFYiJJ3TEshElkoKENZ00m3Nd9tlSDLGJLc7SRrQL_f6-GNv4Tyl45AFIj1maamFhbCgc5oC-YGW6kPLPaWWXmv5wDLQB6FcQiZ7kjnkTsIr5XaM8oSEEIZssQd7xDs7GRkDtqPbmWvrnafXhlDKNJSyDexzf5I8M0R7vLEaxNoWJiYmpRzwnznJSvL6UImiGvcdLeixrATOBBBMaJlYowlserSv3lDOH1J_AU2oyMhNIHcPzgPuRk2d3hAkXKCEXZcXMdXsARoVr4WZ7UHMHDXLPPM1t-feGmQ2vkmlH2DLmyPvM6DAf2W2vB1uV77fPlMwVQsekcPDj2S8XU48dowPZBX5M1Gy3ntiZasbVlGNr6_exKNxR4jyfbMX2Ap8JcgY1kxcc7pJahE3erNU9FG093QhjKUihd5BCHLhQlz4EEuwqBPbxDZN3LMFM6_Y8W5CH7l3QOABsd-MuK2-1-n_tpJAaqI2l9VPHY-dOeTsFakAr27GNwRbmpta9ptemHFJMb-ttOj9TnkFLe2ttFfiLZMJZgrIsBY_FDCKZus1aHqPs22KZ7_Zo3qUu7PNnLdVV6ubmt2fO9b8G2L2NOj_lDNxMcityjCm6wnQf9LHkciumU0L3-RUKb7B202AGsgI-o9rryt9ezjjTtjfKtAM74ZxMzPMVLNUGvsZI8VkYSZaVmkRHn6tShWWo-lyJ-TUh2wGYypFztZJaKulAsiQ2BlSPVcqTjALyhzE5JKJ40v69Ha4dbcE7-nSbriTmktNUk41sxvnwaUxU8hJ6V9XOeM8eZcP8xhDyi-QvDs5OQnrw0eW2SLpq6cPHWqKlyUQ0_R7iJkb9YGYp99BfPTDNhT73zkbMo4kL3Qbj4zjSS2hZZrWpbUMF_Esnoe0aI7iqARdUpbhV8Ozg60iW-BVXUUJLjPIacVxHqzEC0JpZeVyI9IosbqCOKrqnpwyii-Gsmu8yJiVOkpyyvGYI-ykddE8KSr-krJsnqEGX_pvl_oTpsZEyXP0FCX9s5-OBoP-8HRwdn7W_3F4ch5Hmyg57A-Phvg7Hwx-Pj89HZ6evcTR1zps_-UfiqMDUw?type=png" alt=""><figcaption></figcaption></figure>

## Scaling & Interpolation Mechanics

The final recoil effect is computed using a combination of random value selection, scaling multipliers, and easing interpolation. The formulas below illustrate how the final recoil values are determined:

**Final Recoil Calculation:**

$$
FinalPitch=−RecoilScale×StateModifier×R\_{vertical​}
$$

$$
FinalYaw=RecoilScale×StateModifier×R\_{horizontal​}
$$

Each $$C\_{state}$$ value corresponds to a multiplier set in the Recoil Data (e.g., `RecoilScaleSprint`).

**Timeline Easing:**

The system applies easing functions during the timeline interpolation. For a given timeline tick, the eased value is computed as:

$$
EasedValue=Ease(0,Target,t,EaseType,EaseExp,Steps)
$$

Where:

* **Target** is the computed recoil value.
* **t** is the current normalized time (0 to 1).
* **EaseType** could be `EaseIn`, `EaseOut`, or `ExpoOut`, among others.
* **EaseExp** and **Steps** further define the interpolation curve.

### Recoil Reset & Delay

After the recoil is applied, the system waits for a short period (defined by `RecoilResetDelay`) before starting the reset animation. The reset phase, controlled by `RecoilResetSpeed` and its interpolation settings, smoothly returns the camera to a neutral position.

## The Recoil Worker & Component

### UMaySimpleRecoilComponent

This component is designed to be added to your Character or Pawn and is the primary interface for the recoil system. Its responsibilities include:

* **Spawning the Recoil Worker:** Automatically spawns or references an `AMayRecoilWorker` actor.
* **Exposing Key Functions:**
  * **Recoil()**: Triggers the recoil sequence.
  * **OnYawAdded(float Yaw)** and **OnPitchAdded(float Pitch)**: Handle additional user input during recoil.
  * **TrySetADS(bool bNewADS)**: Adjusts the ADS (aiming down sights) state.
  * **UpdatePlayerYawAndPitch()**: Updates the character’s rotation—by default, adding input to the controller.

### AMayRecoilWorker

The `AMayRecoilWorker` actor manages the actual recoil animations using two timelines:

* **AddRecoilTimeline:** Gradually applies the recoil effect using curve assets.
* **ResetRecoilTimeline:** Smoothly resets the camera after recoil.

Key methods include:

* **Recoil\_Implementation():** Starts the recoil timeline.
* **ResetRecoil\_Implementation():** Initiates the reset timeline.
* **GetRecoilYawAndPitchStrength():** Calculates the final recoil strength (using random values or forced limits).
* **OnYawAdded()/OnPitchAdded():** Adjust recoil dynamically based on extra input.

### Default vs. Custom Implementation

The plugin includes a default implementation of both the Recoil Component and Recoil Worker that works seamlessly out-of-the-box. However, if you require custom behavior:

* **Subclass AMayRecoilWorker:** Override methods such as `Recoil_Implementation()` to add extra effects (e.g., camera shakes or custom offsets).
* **Override UpdatePlayerYawAndPitch():** In your Blueprint or C++ subclass, modify how the player’s view is updated.
