Contact Damage
ContactDamage hurts any Hitbox that enters its trigger. Use it for spikes, lava, saw blades, or enemies that hurt the player on touch.
🧱 Setup
- Add
ContactDamageto a GameObject with a collider. The collider is required. - Tick Is Trigger on the collider.
- Set the Damage.
Note
Unity only reports trigger contacts when one of the two objects has a Rigidbody. Add a kinematic Rigidbody to the moving one if hits don’t register.
📐 Inspector Overview
| Field | Description |
|---|---|
| Damage | Damage dealt to each hitbox that enters the trigger |
⚙️ How It Works
flowchart LR
A["Hitbox enters trigger"] --> B["ContactDamage"] --> C["hitbox.Hurt"]
- Damage is dealt once per entry, when a hitbox’s collider enters the trigger.
- The hit point is the closest point on the hitbox’s collider, and the contact object is the damage’s instigator.
- The hitbox’s multiplier and the target’s health modifiers still apply.
Tip
The Hitbox Boss example uses contact damage spheres that hurt the player’s ship on touch.