Core Concepts
Core Concepts
Understand the four building blocks that power every reaction in the system.
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:
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.
Runs heavy math in
LateUpdate()
to avoid fighting the Animator.
⮞ Deep‑dive: Head to the BodyPartReactor page for detailed inspector reference and best‑practice tips.
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 page documents every parameter with practical examples.
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:
Rigidbody velocity
Transform movement delta
Collision normal
Can auto‑destroy the projectile after impact, with an optional delay for particle effects.
⮞ Deep‑dive: Check the HitReactionTrigger page for setup checklists and extension hooks.
How They Talk to Each Other
A HitReactionTrigger registers
OnCollisionEnter
and figures out what it hit and from which direction.It finds the BodyPartReactor sitting on that bone (via
collision.transform
).It climbs the hierarchy to grab the owning HitReactionController.
The controller’s React() loops through its reactor list and triggers the matching bone.
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).
Last updated