Hurtbox 2D
Area where hitboxes damage a Health: on this node or on its nearest parent with Health.
component gameplay.Hurtbox2D
On this page
Try it
Scale damage with a hurtbox
The red attack deals 2 base damage where it overlaps the green target. Multiplier 0 prevents that hit from reducing its 10 health points.
Set Multiplier to 2. The scene restarts and the real hit deals 4 damage: the target has 6 health points and turns orange. Reset restores the zero multiplier.
Starts the scene; open the example parameters to experiment.
Scene3 nodes
Scriptmain.aes
package demo
// The target changes color only after its actual Health takes damage.
script DamageIndicator {
func Update(dt float) {
hp := node.Get<Health>()
if hp.Current < hp.Max {
node.Get<SpriteRenderer>().Tint = Color{1, 0.5, 0.05, 1}
} else {
node.Get<SpriteRenderer>().Tint = Color{0.05, 0.8, 0.25, 1}
}
}
}
Fields
| Name | Type | Default | Description |
|---|---|---|---|
| Area | Rect | (-0.5, -0.5, 1, 1) | Rectangle in this node's space. |
| Shape | enum | box | box uses the rectangle; circle uses the circle inside it. one of: box, circle |
| Multiplier | float | 1 | Damage taken here is multiplied by this, for weak spots and armour. ≥ 0 |
| Active | bool | true | Off ignores hits. |
| Health | NodeRef | none | Health that takes the damage. Empty uses this node or its nearest parent with Health. |
Related guides
- Hurtboxes A Hurtbox 2D is an area in its node's space where hitboxes hurt a Health: the one in its Health field, or the nearest Health on the node or above it.
- Gameplay kit The gameplay module adds the parts most 2D games rebuild by hand: a character controller, hit points, hitboxes and hurtboxes, kill zones, checkpoints with respawn, pickups and timed removal.