Kill zones
A Kill Zone 2D kills a Health whose node position enters the area, or triggers Respawn on a node without Health. Tag limits it to tagged nodes; without a tag every node with Health or Respawn counts. Put one under pits and a wide one below the level.
Walk into the pit in the scene: the character dies and comes back at the start.
Try it
Change the example parameters and compare the result. Reset restores the initial scene.
Starts the scene; open the example parameters to experiment.
Scene6 nodes
FloorLeft
Transform
position[-6, 3]rotation0scale[1, 1]
Rigid Body 2D
typeenumstaticmassModeenumautomassfloat0gravityScalefloat1linearDampingfloat0angularDampingfloat0fixedRotationboolfalsebulletboolfalseallowSleepbooltrueinterpolateboolfalselayerlayer0masklayer mask-1
FloorRight
Transform
position[12.5, 3]rotation0scale[1, 1]
Rigid Body 2D
typeenumstaticmassModeenumautomassfloat0gravityScalefloat1linearDampingfloat0angularDampingfloat0fixedRotationboolfalsebulletboolfalseallowSleepbooltrueinterpolateboolfalselayerlayer0masklayer mask-1
Wall
Transform
position[-14, 0]rotation0scale[1, 1]
Rigid Body 2D
typeenumstaticmassModeenumautomassfloat0gravityScalefloat1linearDampingfloat0angularDampingfloat0fixedRotationboolfalsebulletboolfalseallowSleepbooltrueinterpolateboolfalselayerlayer0masklayer mask-1
Player
Transform
position[0, 0]rotation0scale[1, 1]
Rigid Body 2D
typeenumkinematicmassModeenumautomassfloat0gravityScalefloat1linearDampingfloat0angularDampingfloat0fixedRotationbooltruebulletboolfalseallowSleepboolfalseinterpolatebooltruelayerlayer0masklayer mask-1
Camera
Transform
position[0, 0]rotation0scale[1, 1]
Virtual Camera 2D
priorityint0outputstring""zoomfloat0blendTimefloat0.5blendCurveCurve{ ease=inOutQuad }timeDomainenumunscaleduseBoundsboolfalseboundsRect[0, 0, 0, 0]snapToPixelsboolfalse
Camera Follow 2D
targetNodeRefnode("d6500000000000000000000000000004")deadzoneRect[0.4, 0.4, 0.2, 0.2]dampingVec2[5, 5]lookaheadVec2[0.2, 0]maxLookaheadVec2[2, 1]lookaheadSmoothingfloat3snapDistancefloat20
Scriptmain.aes
package demo
import (
"aego/debug"
"aego/input"
)
// Player falls into the pit, dies and respawns at the start.
script Player {
func Update(dt float) {
m := node.Get<Motion2D>()
x := 0.0
if input.Down(input.KeyA) || input.Down(input.KeyLeft) {
x -= 1
}
if input.Down(input.KeyD) || input.Down(input.KeyRight) {
x += 1
}
m.Move(x)
if input.KeyPressed(input.KeySpace) || input.KeyPressed(input.KeyW) || input.KeyPressed(input.KeyUp) {
m.Jump()
}
if input.KeyReleased(input.KeySpace) || input.KeyReleased(input.KeyW) || input.KeyReleased(input.KeyUp) {
m.JumpReleased()
}
hp := node.Get<Health>()
p := node.WorldPosition()
debug.Text(Vec2{p.X - 0.6, p.Y - 1}, "hp " + string(hp.Current), Color{1, 1, 1, 1})
}
}