Getting Started

Get Started

Get up and flinching in just a few minutes. This section walks you through importing the package, running the sample scene, and a quick‑start setup on your own character prefab.


1 Importing the Package

1.1 Asset Store / .unitypackage

  1. Download from your Asset Store library.

  2. Double‑click the .unitypackage → the Import dialog opens.

  3. Keep every file checked and click Import.

Tip: Re‑import safe – you can update over an existing install without deleting anything first.


2 Running the Demo Scene

  1. Navigate to ProceduralHitReactions/Scenes/DemoScene.

  2. Open DemoScene.unity and press Play.

  3. Controls:

    • W A S D – move the First‑Person Controller.

    • Mouse – look around.

    • Left Click – shoot test projectiles that trigger reactions.

  4. Observe how each hit makes the mannequin twist and re‑align.

Want to see heavier reactions? Select a BodyPartReactor in the Hierarchy during Play Mode and assign the Heavy Hit profile.


3 30‑Second Setup on Your Own Prefab

Follow these steps to feel a reaction instantly; we’ll fine‑tune later.

Step
Action

1

Add HitReactionController to the root GameObject that holds the character’s Animator. In cases where you are not using animations, create a empty Animation Controller and assign it.

2

Create a new Animator Layer (Override, Weight = 1). No animation clips required – the system drives the weight.

3

For every bone you want to react (e.g., Chest, Head, LeftArm): a) Add a BodyPartReactor component. b) Drag the bone transform into Bone. c) Assign the included Raction profile. d) (Optional) Add a Collider + Rigidbody (kinematic) for precise impact detection.

4

Back on the HitReactionController, add each reactor to Reactors []. Also set the layer index to the layer you created in your animation controller.

5

Trigger a test hit:

// inside any test script
yourController.React("Chest", -transform.forward, transform.position + transform.forward);
``` |

You should see the bone twitch in Scene view. 🎉

---
## 4  Making Projectiles & Weapons React

1. Add **`HitReactionTrigger`** to any projectile prefab (bullet, rocket, sword blade, fist collider…).
2. Set **React Layers** to include only the layers that should trigger reactions (usually your *Characters* layer).
3. On impact, the trigger automatically finds the correct `BodyPartReactor` and calls `React()` – **no code needed**.

```csharp
// Example: spawning a hit‑reacting bullet
var bullet = Instantiate(bulletPrefab, muzzle.position, muzzle.rotation);
bullet.GetComponent<HitReactionTrigger>().reactLayers = LayerMask.GetMask("Characters");

Note: The trigger tries Rigidbody velocity first, then transform movement, and finally the collision normal to deduce hit direction.


Next Steps

  • Dive into Core Concepts for a deeper look at each component.

  • Check out Recipes & Workflows to apply the system to props, creatures, or networked games.

Last updated