+1 vote

Hi! Correct me if I'm wrong, but when you use instance and add child on a scene you add it as a child of your node, and the first child retains its name and can be referenced normally, but subsequent ones are numbered, ie their names change.

What I wanna know is what's the best way to invariably control all these different instanced child copies of the same scene at once. For example if I have a player character that could shoot multiple bullets at a time, but with a button press I want all the bullets to perform a function from their code, what are the ways to do that?

Thanks in advance <3

Godot version 3.2.3
in Engine by (24 points)

1 Answer

+1 vote
Best answer

You should put all of the bullets into a group and then call get_tree().get_nodes_in_group() to get all your bullets. Then iterate through the resulting array and can whatever method you need on them.

by (7,190 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.