Tags
Tags names groups this node belongs to; scripts find them with scene.WithTag.
component engine.Tags
On this page
Try it
Find a parent tag
The target has the tag Enemy.Flying. A query for Enemy also finds it, so the marker is green.
Expand Tags in the Inspector and replace Enemy.Flying with Ally. The scene restarts and the actual Enemy query no longer finds the target; the marker turns orange. Reset restores Enemy.Flying.
Starts the scene; open the example parameters to experiment.
Scene2 nodes
Scriptmain.aes
package demo
// HasTag queries the scene index, including dot-separated parent tags.
script TagIndicator {
func Update(dt float) {
if node.HasTag("Enemy") {
node.Get<SpriteRenderer>().Tint = Color{0.05, 0.8, 0.25, 1}
} else {
node.Get<SpriteRenderer>().Tint = Color{1, 0.5, 0.05, 1}
}
}
}
Fields
| Name | Type | Default | Description |
|---|---|---|---|
| Tags | []string | [] | Dot-separated names like Enemy.Flying; a node tagged Enemy.Flying is also found by Enemy. |
From a script
Tags are read from scripts through aego/scene: find every node with a tag, or check a node you collided with.
package game
import (
"aego/log"
"aego/scene"
)
script CountEnemies {
var found []NodeRef
func Ready() {
for i := 0; i < 32; i++ {
found = append(found, nil)
}
n := scene.WithTag("Enemy", found)
log.Info("enemies in the level: " + string(n))
}
}