Managing groups : list all, delete...

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By atom

I’m looking at the doc but can’t find a way to list all “active” groups. Something like a :

get_tree().get_groups()

that will return an array listing all groups of the scene.
I need to build and destroy many temporary groups. So I would like to iterate on that list to prevent duplicate group name. For now I use the instance id of the object that “created” the group as the group name to make sure it’s unique, but it seams stacky and inefficient.
How Godot handle groups ? If I build a group by adding members then removing all, what happens to that group name, its reference is deleted ? so I shouldn’t worry or does it stacks in some internal variable for further use and then it could be problematic.
Maybe I shouldn’t worry.

:bust_in_silhouette: Reply From: kidscancode

Groups are not objects, they are “tags” assigned to objects. You don’t create a group, you stick a tag on a Node, and then you can ask “give me the nodes with this tag”.