HitReactionTrigger
HitReactionTrigger Inspector
HitReactionTrigger
is a drop‑in component for any projectile, melee weapon, or explosion fragment that should cause procedural reactions on impact. It handles collision detection, figures out the best hit direction, and calls HitReactionController.React()
—so you don’t have to write a single line of glue code.
Add via: Component ▸ Hit Reactions ▸ Hit Reaction Trigger or include it in your projectile / weapon prefab.
Inspector Reference
1. Which target layers should react?
React Layers
Everything
(bitmask)
Only collisions with these layers will forward a React()
call. Exclude Environment, Terrain, etc., to avoid unnecessary processing.
2. Lifecycle
Destroy On Hit
✔️
If true, destroys the projectile GameObject after a successful hit—ideal for bullets and arrows.
Destroy Delay
0
Time (seconds) to wait before destroying. Useful when you need to play impact VFX first.
(All other properties are hidden—it’s intentionally lightweight.)
How It Works
OnCollisionEnter fires.
Checks if the other collider’s layer is inside React Layers. If not → exit.
Tries to get a
BodyPartReactor
oncollision.transform
. If none → exit.Searches parent hierarchy for a
HitReactionController
.Calculates hit direction using fallback order:
Rigidbody velocity (
Rigidbody.linearVelocity
).Transform delta from previous frame (
transform.position - _lastPos
).Collision normal (negated) if object didn’t move.
Calls
controller.React(part.name, hitDir, contactPoint)
.Optionally destroys itself after Destroy Delay.
Best Practices
Separate layers per team: In PvP games, configure PlayerProjectiles vs. EnemyCharacters to avoid friendly fire reactions.
Melee weapons: Place a thin Trigger Collider along the blade and enable
Is Trigger
on the collider. The component still works; just swapOnCollisionEnter
forOnTriggerEnter
if you need continuous overlap.Grenade shrapnel: Spawn multiple sphere colliders with triggers enabled; each can carry a
HitReactionTrigger
that destroys itself on the first contact.Pooling systems: Remember to reset (or disable)
Destroy On Hit
if the pooled projectile should live through multiple bounces.
Extending the Trigger (Hooks)
Need custom logic (e.g., apply damage, play VFX)? Derive a subclass:
(Override method not in base yet? Fork the script—only 60 lines!)
Next Up
With all four components covered, jump into Recipes & Workflows to apply them in common gameplay scenarios.
Last updated