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

  1. Add ContactDamage to a GameObject with a collider. The collider is required.
  2. Tick Is Trigger on the collider.
  3. 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

FieldDescription
DamageDamage 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.