How to add nodes to a group ?

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

I want to use a group to connect a signal of a large number of scenes instances to a root node, on ready time, and I want to avoid putting the connect call into the emitters.

I’m sorry for the noobish question, believe me or not I’m stuck with that. I can add a group into the inspector but it seems cumbersome to manually enter the group name into every node so I think the editor gives a solution for that.

Are you looking for Node — Godot Engine (stable) documentation in English ?

moechofe | 2016-12-06 21:02

Thanks for the proposal but it’s not what i’m looking for. I want to choose into the tree the nodes to add using the editor.

If I use scripting I must iterate into childrens, with a for loop, so the groups becomes useless. But this could be a workaround in order to connect a lot of nodes :wink:

DriNeo | 2016-12-06 21:23

Not sure if I understand…

Mass group and mass signal assignment is not possible.

Using scene instancing, you can add it to a group and then add it to the tree with the group already assigned (again, not possible for signals if are connected to a parent, but can be done via script on _ready).

eons | 2016-12-07 02:25

:bust_in_silhouette: Reply From: puppetmaster-

you can call group…

get_tree().call_group(0, "groupName", "connect", .....)
:bust_in_silhouette: Reply From: DriNeo

My workaround.

I create the group in the scene that will be instanced.

enter image description here

This scene instanced many times in the level scene.

enter image description here

Connect every node of the group in the level script.
enter image description here

You can also programmatically use add_to_group in 3.x if this helps anyone:

Scripting (continued) — Godot Engine (3.1) documentation in English

Ransome | 2019-04-30 14:26