Can a node be in "Groups" tap for Group without being a child to the node creating the Group?

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

I am working on a node in my scene tree and i will like to add other nodes in same scene as a member to a group created by the node i am currently working on. My question is can a node be in a Group without being a child to the node creating the group?

:bust_in_silhouette: Reply From: timothybrentwood

Yes. Groups are tagged at the SceneTree level, not the node level.

That’s why you use get_tree().get_nodes_in_group("some_group") not get_node("some_random_node").get_nodes_in_group("some_group"). You can either use add_to_group("some_group") from inside the node’s script or tag it in the editor:

thank you very much bro.

gieyan | 2021-12-08 18:57