# Core Concepts

## Core Concepts

> Understand the **four building blocks** that power every reaction in the system.

```
[Projectile / Blade]
      │   OnCollisionEnter()
      ▼
HitReactionTrigger ─► HitReactionController ─► BodyPartReactor ─► ReactionProfile
```

Each block has a single responsibility, making the system easy to extend and reason about. Skim the summaries below, then jump into the dedicated pages for full inspector field breakdowns.

***

### 1. HitReactionController

**Role:** *Per‑character hub that receives incoming hits and forwards them to the right bone.*

* Lives on the **root GameObject** that also holds the `Animator`.
* Maintains a list of **BodyPartReactors** to loop through on `React()` calls.
* Exposes a single public API:

  ```csharp
  void React(string partName, Vector3 hitDirection, Vector3 hitPoint);
  ```
* Drives the weight of a dedicated **Animator Layer** so pose offsets stay additive.

⮞ Tip: You can use the exposed api script React() to trigger reaction in your own scripts, or add the HitReactionTrigger module to your projectile.

***

### 2. BodyPartReactor

**Role:** *Applies translation & rotation offsets to one specific bone according to a ReactionProfile.*

* Added to **each bone** that should respond (Chest, Head, arms…).
* Computes direction‑aware and/or random offsets every hit.
* Handles **blend‑in / blend‑out**, axis locks, carry‑over, slow‑blend, and follow‑through chains.  >*DEPRECATED in 1.1 and moved to ReactionProfile*
* Runs heavy math in `LateUpdate()` to avoid fighting the Animator.

⮞ *Deep‑dive:* Head to the [**BodyPartReactor** ](https://ironsami-studio.gitbook.io/proceduralhitreactions/modules/bodypartreactor)page for detailed inspector reference and best‑practice tips.

{% hint style="warning" %}
**Procedural Hit Reactions 1.1 – Important Changes**

In version 1.1, the values previously found within the **BodyPartReactor** have been moved to the new **Reaction Profiles** system. The **BodyPartReactor** now only contains:

* **Bone Reference**
* **Reaction Profile**
* **Follow Objects**
* **Per-Bone Multiplier** (new), which allows you to adjust the intensity and duration of the reaction per bone.

These changes are part of the updated and more flexible profiles/body part reactor system, designed to give you greater control and customization.
{% endhint %}

***

### 3. ReactionProfile

**Role:** *ScriptableObject that stores timing, strength, and axis rules—re‑usable across characters.*

* **Timing:** duration, blend‑in, blend‑out speeds, custom curve.
* **Rotation / Translation:** enable toggles, strength vectors, random vs. directional modes.
* **Hit‑direction source:** choose between bullet vector or contact‑point direction.
* **Axis masks:** per‑axis on/off switches for both rotation and translation.

⮞ *Deep‑dive:* The [**ReactionProfile**](https://ironsami-studio.gitbook.io/proceduralhitreactions/modules/reaction-profiles) page documents every parameter with practical examples.

{% hint style="warning" %}
Since 1.1 more options have been moved to the ReactionProfiles module from the BodyPartReactor module. See the image below
{% endhint %}

<figure><img src="https://2750945321-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCksxjdhoQvkDgI7d2ROJ%2Fuploads%2FOD4GhxzlH1lFnw4SRWXn%2Fimage.png?alt=media&#x26;token=a5f00ce8-5391-458a-87d2-6511917a23e0" alt=""><figcaption><p>ReactionProfiles.cs</p></figcaption></figure>

***

### 4. HitReactionTrigger

**Role:** *Drop‑in helper component that auto‑detects collisions and calls `React()` with the correct data.*

* Works on **projectiles, melee blades, fists, explosions**—anything with a `Collider`.
* Filters collisions via a **React Layers** mask so terrain and walls won’t trigger hits.
* Determines hit direction by falling back gracefully:
  1. Rigidbody velocity
  2. Transform movement delta
  3. Collision normal
* Can auto‑destroy the projectile after impact, with an optional delay for particle effects.

⮞ *Deep‑dive:* Check the [**HitReactionTrigger** ](https://ironsami-studio.gitbook.io/proceduralhitreactions/modules/hitreactiontrigger)page for setup checklists and extension hooks.

***

### How They Talk to Each Other

1. A **HitReactionTrigger** registers `OnCollisionEnter` and figures out *what* it hit and *from which direction*.
2. It finds the **BodyPartReactor** sitting on that bone (via `collision.transform`).
3. It climbs the hierarchy to grab the owning **HitReactionController**.
4. The controller’s **React()** loops through its reactor list and triggers the matching bone.
5. The **BodyPartReactor** pulls values from its assigned **ReactionProfile**, blends offsets, and writes transforms in `LateUpdate()`.

This separation keeps data generic (profiles), math local (reactor), plumbing simple (controller), and input flexible (trigger).
