Kill Zone 2D
Kills a Health that enters the area, or respawns a node with Respawn and no Health.
component gameplay.KillZone2D
On this page
Try it
Filter a kill zone by tag
The target tagged Player is inside the red zone. Tag Other does not match it, so its Health remains alive.
Set Tag to Player. After the scene restarts, the real kill zone kills the target; its Health indicator turns orange. Reset restores the mismatched tag and a living target.
Starts the scene; open the example parameters to experiment.
Scene8 nodes
Zone
Transform
position[0, 0]rotation0scale[1, 1]
Scriptmain.aes
package demo
// The indicator reports the tagged target's actual Health state.
script ZoneIndicator {
@export var Target NodeRef
func Update(dt float) {
if Target.Get<Health>().Dead {
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 | (-10, -1, 20, 2) | Rectangle in this node's space. |
| Tag | string | "" | Only nodes with this tag; empty affects every node with Health or Respawn. |
Related guides
- Kill zones A Kill Zone 2D kills a Health whose node position enters the area, or triggers Respawn on a node without Health.
- 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.