Hitbox

The Hitbox component links a collider to a damage system. It enables per-body-part damage scaling and channels damage to the associated Health component on the parent.

Summary

This component:

  • Must be placed on a child GameObject with a Collider
  • Multiplies incoming damage by a configurable value
  • Sends damage to the parent Health component
  • Emits an onHit event when hit

Fields

FieldTypeDescription
damageMultiplierfloatScales incoming damage. Use for headshots, limbs, etc. (e.g., 2.0 for double damage).
hitColliderCollider (read-only)The collider attached to this hitbox GameObject.
onHitUnityEvent<DamageData>Called every time this hitbox receives damage.

Public Methods

MethodDescription
void Hurt(DamageData damage)Applies damage to the parent Health component, scaled by damageMultiplier. Triggers onHit event.

Setup Instructions

  1. Add a Health component to the root object of your character or entity.
  2. Add Hitbox to any child objects that have colliders (e.g., head, torso).
  3. Configure damageMultiplier per region:
    • Head: 2.0
    • Torso: 1.0
    • Limbs: 0.5

Example

var damage = new DamageData
{
    damagePoints = 20f,
    hitPoint = transform.position,
    instigator = player,
};

hitbox.Hurt(damage);

Note

A Hitbox only relays damage — it does not store health itself.

Tip

Use the onHit event to spawn VFX or trigger impact sounds when a hitbox is struck.

Warning

The parent GameObject must have a Health component for damage to be processed.

See Also Health

DamageData

ProjectileAmmo