Hitbox
The Hitbox connects a collider to the Health system. Attacks hurt the hitbox, and the hitbox scales the damage and forwards it to the Health on its own GameObject or a parent.
🧱 Setup
- Add
Hitboxto any GameObject with a Collider. The collider is required. - Make sure a
Healthsits on the same GameObject or a parent. - Set the Damage Multiplier for this part of the body.
Note
Add several hitboxes to one character (head, torso, limbs), each with its own multiplier. They all feed the same Health.
📐 Inspector Overview
| Field | Description |
|---|---|
| Damage Multiplier | Scales incoming damage. 1 is normal, 2 is double (a headshot), 0.5 is half (armor) |
| On Hit (DamageData) | Raised every time this hitbox is hurt, with the damage after the multiplier. Use it for hit effects, sounds or damage numbers |
⚙️ How It Works
flowchart LR
A["Hit"] --> B["x Damage Multiplier"] --> C["Health"]
B --> D["On Hit"]
- Damage is multiplied first, then sent to the
Health, then On Hit fires. - A disabled hitbox ignores hits. Disable it to make one body part immune.
- A hitbox without a
Healthabove it still raises On Hit, which is handy for targets that only react to hits.
Tip
The Hitbox Boss example uses hitboxes with multipliers of 2, 1 and 0.5 to show weak and armored spots.