BodyPartReactor
BodyPartReactor Inspector
BodyPartReactor
is the workhorse that drives offsets on a single bone. You’ll add one component per bone that should flinch—typically Chest, Head, UpperArms, maybe Pelvis.
Add via: Component ▸ Hit Reactions ▸ Body Part Reactor or drag the prefab helper onto the bone in the Hierarchy.
Inspector Reference
1. References
Bone
The Transform to animate (usually the same object the script is on).
2. Reaction Profile
Profile
None
Assign a ReactionProfile
asset that defines timing and strength.
Use Local Hit Direction
✔️
Convert incoming vector into bone local space for more intuitive direction locking. Disable if you want world‑space comparison (rare).
Override On Hit
❌
Off (default): ignore new hits while weight > 0 (prevents jitter on rapid fire). On: every hit resets timer even if still reacting.
Additive
✔️
Add offsets on top of the animation pose. Disable to fully replace animation (useful on props without an Animator).
Auto‑Invert Back Hits
❌
If forward local Z is negative, flip hit direction so reactions always push backwards. Handy when character faces away from camera in 2D sidescrollers.
3. Advanced Blending
Blend Reset Mode
HardReset / ScaledCarryOver
HardReset: weight drops to 0 on new hit.ScaledCarryOver: keep fraction of current weight (good for auto‑fire).
Carry‑Over Scale
0.3
How much weight to preserve when using ScaledCarryOver.
Slow Blend Mode
❌
Multiplies Blend‑In Speed by Slow Blend Multiplier—simulate sluggish reactions on heavy impacts.
Slow Blend Multiplier
0.4
Weight factor (0–1) applied when Slow Blend Mode is active.
Offsets From Current Pose
❌
Calculate offsets relative to current pose instead of bind pose—prevents drift when base animation is already rotated (e.g., leaning).
4. Follow‑Through (optional)
Follow Transforms [ ]
—
Drag extra bones or objects (e.g., shoulder pads, hair bones) that should inherit a fraction of this bone’s reaction.
Follow Rot Weight
0.2
0–1 fraction of rotation offset applied to followers.
Follow Pos Weight
0.1
0–1 fraction of translation offset applied to followers.
How It Blends
React() is called → stores target rotation/position deltas.
Each frame in
Update()
it ramps weight up (Blend‑In) or down (Blend‑Out) based on profile.In
LateUpdate()
it applies offsets:Additive Off:
Lerp/Slerp
bone from bind pose to target.Additive On: multiplies current pose by delta. Keeps Animator motion intact.
Animator Layer Weight is set to match
weight
, ensuring your override layer stays in sync.
Best Practices
Chest first: Start with a single chest reactor; once tuned, copy component to other bones.
Carry‑Over for gunfire: Use ScaledCarryOver with a 0.2–0.4 scale to avoid flickering.
Inertia chains: Let shoulders follow chest, and head follow shoulders for natural delay.
Disable Translation on feet: Leg rigs often can’t handle additive position offsets—keep them rotation‑only.
Runtime Tweaks via Code
You can toggle or swap profiles at runtime:
Need to disable reactions altogether? Just enabled = false
on the component.
Next Up
See the HitReactionController Inspector to understand how multiple reactors tie back into one character‑level controller.
Last updated