+5 votes

Hello

I have a group that has more than one member. I want to access all the members in that group, not only one. How can i do this?

If it is not possible to do this, then is there a way to tag objects in godot? (Like in Unity for example).

Thanks.

in Engine by (71 points)

1 Answer

+10 votes
Best answer

You can get an Array with each member of your group doing:

var my_group_members = get_tree().get_nodes_in_group("my_group")

You can also call an specific method for all members:

get_tree().call_group("my_group","my_function",args...)

If you need to do something with your group:

for member in get_tree().get_nodes_in_group("my_group"):
    member.my_function(args...)
by (322 points)
selected by
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 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 webmaster@godotengine.org with your username.