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.
Scene3 nodes
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
| Name | Type | Default | Description |
|---|---|---|---|
| Area | Rect | (-0.5, -0.5, 1, 1) | Rectangle in this node's space. |
| Tag | string | "" | Only nodes with this tag; empty accepts every node with Motion 2D. |
| Once | bool | true | Removes the pickup after the first collection. |
| Despawn | bool | false | 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.
Related guides
- Pickups A Pickup 2D fires
Collected(by)when a node enters it: a tagged node, or any node with Motion 2D. - 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.