ProceduralHitReactions
  • Welcome
  • Getting Started'
    • Getting Started
    • Core Concepts
  • Recipes & Workflows
  • Advanced
  • Modules
    • Reaction Profiles
    • BodyPartReactor
    • HitReactionController
    • HitReactionTrigger
  • Extra
    • Troubleshooting & FAQ
Powered by GitBook
On this page
  • Core Concepts
  • 1. HitReactionController
  • 2. BodyPartReactor
  • 3. ReactionProfile
  • 4. HitReactionTrigger
  • How They Talk to Each Other
  1. Getting Started'

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:

    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.

  • 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:

    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 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).

PreviousGetting StartedNextRecipes & Workflows

Last updated 10 days ago