A character hurt box is a 2D trigger (and collider) used to register damage. Without a CharacterHurtBox a character can only be sent the Kill() message which triggers death but not damage.
The CharacterHurtBox component is typically added to a child GameObject of the characters model or sprite. This way it will flip when the model or sprite is flipped.
This component also requires some kind of Collider2D (for example a BoxCollider2D) and because it moves should also include a Rigidbody2D.
The Collider2D must be a trigger, the Rigidbody2D must be kinematic with a gravity scale of 0:
The default layer for a Character Hurt Box is the Character layer.
If you are deviating from the standard layers then make sure:
- Your character does not collide with the hurt boxes layer (i.e. its not a Geometry or Passthrough layer)
- The layer collides with the hazard/enemy projectiles layer (hitting an enemy or hazard is what triggers the damage).
Tip: If you have a HurtBox set up you often don't need any other colliders as you can also use the hurt box to collect items and perform other interactions.