+2 votes

Hello,

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

enter image description here
is there a demo/tutorial for these kind of tools ?

thanks

in Engine by (38 points)

2 Answers

+7 votes
Best answer

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 getnodesin_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

by (269 points)
edited by
0 votes

⚠ 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): https://docs.godotengine.org/en/latest/tutorials/scripting/groups.html

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.

by (42 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.