Advanced
Advanced
Deep‑dive mechanics, edge‑case tweaks, and performance guidelines for shipping projects.
6.1 Axis Locks & Directional Hits
Concept
Axis locks zero‑out specific axes after the random / directional offset has been chosen. Use them to guarantee that a character never rolls upside‑down or that a turret stays level.
Workflow
In your
ReactionProfile
, set Rotation Axis Mask or Translation Axis Mask (values 0–1).Toggle Use Local Hit Direction in
BodyPartReactor
to decide whether the mask is applied in bone‑local space (common) or world space (rare).Combine with Use Contact‑Point Direction to switch between origin → bone vectors and projectile velocity.
Tip: For top‑down games, lock the Y rotation (pitch) so hits only spin characters on the Z‑axis.
6.2 Follow‑Through Chains
Goal
Create natural secondary motion—gear, hair, or child bones lag behind the main impact.
Setup
On the primary
BodyPartReactor
(e.g., Chest) add followers:Drag the Head bone into Follow Transforms list.
Follow Rot Weight ≈ 0.25, Follow Pos Weight ≈ 0.1.
On Head you can still keep its own reactor for direct hits.
Best Practices
Chain order: torso → shoulders → head → props.
Keep weights < 0.5 to avoid double‑moving (follower + self‑reactor).
6.3 Slow‑Blend for Heavy Impacts
Enable Slow Blend Mode to multiply the profile’s Blend‑In Speed by Slow Blend Multiplier (0–1). This makes the reaction appear heavier without changing strength.
6.4 Performance & GC
Per‑frame math
All trig done on 3–10 bones → sub‑0.1 ms on modern CPUs.
Garbage
Allocation‑free. Randoms use UnityEngine.Random.Range
(no boxing).
Physics cost
System itself adds none; use primitive colliders and pooled projectiles to keep PhysX cheap.
Burst / DOTS
Not required—system is already CPU‑light, but you can port BodyPartReactor.Update()
to Burst if profiling shows spikes.
6.5 Networking / Determinism
Because the system is pure math on floats and doesn’t sample animation curves at runtime, reactions can be reproduced deterministically across clients.
Sync only these parameters on hit:
partName
(string or enum)hitDirection
(normalized Vector3, 16 bits per component works)hitPoint
(optional—needed only if profile uses contact‑point direction)
On each client call
React()
with the same values.Ensure all clients load identical ReactionProfile assets (GUID match). Prefer AssetBundles or Addressables to avoid mismatches.
Rollback netcode: Because reactions are purely cosmetic, you can skip rewinding bones—simply apply the hit on the presentation frame.
6.6 Editor Automation & Gizmos
Coming in a future update: Bone Auto‑Setup Wizard that scans your rig and adds reactors to common bones with a single click.
Enable Gizmos to visualize hit directions and axis masks while tuning profiles in Play Mode.
Last updated