Hitbox Component
The Hitbox
component enables an object to receive damage and interact with the Health
system. It works in tandem with the Health
component to apply incoming DamageData
such as from projectiles or explosions to a specific target.
π― Purpose
- Detects damage through colliders
- Multiplies incoming damage using a configurable scalar
- Sends the result to a connected health or damage processing system
π§± Setup Instructions
- Add the
Hitbox
script to any GameObject that contains a Collider. - Set the Damage Multiplier to scale damage for this body part (e.g. headshot = 2.0).
- Hook up the On Hit UnityEvent to send damage to a
Health
orHitpoint
target.
Note
You can add multiple Hitbox
components across a characterβs body (e.g., head, torso, limbs), each with its own multiplier.
π Inspector Overview
Field | Description |
---|---|
Damage Multiplier | Scales the incoming damage (e.g., 1.0 = normal, 2.0 = double damage) |
On Hit (DamageData) | Event triggered when this hitbox is struck. Use it to forward the DamageData to your Health or custom damage handler. |
β Ideal For
- Player and enemy limbs
- Armor weak points
- Vehicles with destructible modules
Tip
Pair this with a Health
component on the root GameObject to fully enable health loss, VFX triggers, and death logic.