Aego Русский

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.
Open in AegoDownload example project
Scene8 nodes
Zone
Transform
position[0, 0]rotation0scale[1, 1]
Kill Zone 2D
areaRect[-2, -1.5, 4, 3]tagstring"Other"
Top
Transform
position[0, -1.5]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")tintColor#ef4444ffsizeVec2[4, 0.12]
Bottom
Transform
position[0, 1.5]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")tintColor#ef4444ffsizeVec2[4, 0.12]
Left
Transform
position[-2, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")tintColor#ef4444ffsizeVec2[0.12, 3]
Right
Transform
position[2, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")tintColor#ef4444ffsizeVec2[0.12, 3]
Target
Transform
position[0, 0]rotation0scale[1, 1]
Tags
tags[]string["Player"]
Indicator
Transform
position[0, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")tintColor#0dcc40ffsizeVec2[2, 2]
Camera
Transform
position[0, 0]rotation0scale[1, 1]
Camera 2D
zoomfloat40clearColorColor#111827ffscaleenumfitVirtualvirtualVec2[960, 540]activebooltrue
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

NameTypeDefaultDescription
AreaRect(-10, -1, 20, 2)

Rectangle in this node's space.

Tagstring""

Only nodes with this tag; empty affects every node with Health or Respawn.