Aego Русский

Lifetime

Removes the node after some seconds: back to its pool or destroyed.

component gameplay.Lifetime
On this page

Try it

A node with a lifetime

The bar reads the running Lifetime's Remaining value: it is long above 30 seconds and short below. The node disappears at zero.

Change Seconds from 60 to 8. The bar becomes short and its node disappears after eight game seconds. Reset restores the original node.

Starts the scene; open the example parameters to experiment.
Open in AegoDownload example project
Scene3 nodes
Timer
Transform
position[0, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")tintColor#f59e0bffsizeVec2[6, 1.5]orderint1
Track
Transform
position[0, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")tintColor#374151ffsizeVec2[7, 2]
Camera
Transform
position[0, 0]rotation0scale[1, 1]
Camera 2D
zoomfloat40clearColorColor#111827ffscaleenumfitVirtualvirtualVec2[960, 540]activebooltrue
Scriptmain.aes
package demo

// The bar reads the actual runtime Remaining value, not the configured field.
// It disappears with the node when Lifetime reaches zero.
script TimerDisplay {
    func Update(dt float) {
        remaining := node.Get<Lifetime>().Remaining
        if remaining > 30 {
            node.Get<SpriteRenderer>().Size = Vec2{6, 1.5}
        } else {
            node.Get<SpriteRenderer>().Size = Vec2{2, 1.5}
        }
    }
}

Fields

NameTypeDefaultDescription
Secondsfloat2

Seconds the node lives.

≥ 0
Unscaledboolfalse

Counts real time, also while paused or slowed down.

Despawnboolfalse

Returns the node to its pool instead of destroying it.

Runtime state

Values the component has while the game runs. They are not saved with the scene.

NameTypeDefaultDescription
Remainingfloat0

Seconds left.