Aego Русский

Pickup 2D

Fires Collected when a node enters the area; with Once the pickup then disappears.

component gameplay.Pickup2D
On this page

Try it

Collect with a matching tag

The blue node tagged Player is inside the yellow pickup area. Tag Other does not match, so Collected does not fire.

Set Tag to Player. After the scene restarts, the real pickup emits Collected and its area turns green. Once is off so the pickup stays visible. Reset restores the mismatched tag.

Starts the scene; open the example parameters to experiment.
Open in AegoDownload example project
Scene3 nodes
Indicator
Transform
position[0, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")tintColor#eab308ffsizeVec2[3, 2]
Pickup 2D
areaRect[-1.5, -1, 3, 2]tagstring"Other"onceboolfalse
Target
Transform
position[0, 0]rotation0scale[1, 1]
Tags
tags[]string["Player"]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000d00")tintColor#38bdf8ffsizeVec2[0.6, 0.6]orderint1
Camera
Transform
position[0, 0]rotation0scale[1, 1]
Camera 2D
zoomfloat40clearColorColor#111827ffscaleenumfitVirtualvirtualVec2[960, 540]activebooltrue
Scriptmain.aes
package demo

// The color changes only on the actual Collected signal, not by reading Tag.
script PickupIndicator {
    var collected Connection

    func Ready() {
        collected = node.Get<Pickup2D>().Collected.Connect(OnCollected)
    }

    func OnCollected(by NodeRef) {
        node.Get<SpriteRenderer>().Tint = Color{0.05, 0.8, 0.25, 1}
    }
}

Fields

NameTypeDefaultDescription
AreaRect(-0.5, -0.5, 1, 1)

Rectangle in this node's space.

Tagstring""

Only nodes with this tag; empty accepts every node with Motion 2D.

Oncebooltrue

Removes the pickup after the first collection.

Despawnboolfalse

Returns the pickup to its pool instead of destroying it.

Signals

Collected signal

signal Collected(by NodeRef)

Fires with the node that took the pickup.