is the group tool some kind of tag for objects()?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mshka
:warning: Old Version Published before Godot 3 was released.

Hello,

is the group option some kind of equivalent to tags in unity( or is there something else that has the same goal??)


is there a demo/tutorial for these kind of tools ?

thanks

:bust_in_silhouette: Reply From: zendorf

You can tag a node with code via the set_meta command. This is closer to Unity’s tag system. For example:

myNode.set_meta("type", "enemy")    # set myNode type to "enemy"
var getType = myNode.get_meta("type")    # get the type of myNode

The advantage of the groups system is that you can create them visually via the Group Editor as well as via code. You can also return a list of nodes in a group using the get_nodes_in_group command, which is more difficult to do using metatags.

There is a small amount of documentation on groups at http://docs.godotengine.org/en/latest/tutorials/step_by_step/scripting_continued.html

:bust_in_silhouette: Reply From: jeroenheijmans

:warning: I’m a total beginner at Godot when I write this. Having said that…

The link from the other answer died. Here’s one that works (in March 2023 at least): Groups — Godot Engine (latest) documentation in English

Groups in Godot work like tags in other software. You can add a node to as many groups as you want. Then, in code, you can use the SceneTree to:

  • Get a list of nodes in a group.
  • Call a method on all nodes in a group.
  • Send a notification to all nodes in a group.

This is a useful feature to organize large scenes and decouple code.

So it seems the straight up answer to the original question is “Yes”, according to the official docs it’s somewhat equivalent to tags.