0 votes

My code works fine with one enemy entity but as soon as I bring in an "Enemy2" my "get_node("../Enemy)" doesn't work on the "Enemy2" can I do something so it gets all nodes that start with "Enemy" in their name?

in Engine by (62 points)

1 Answer

0 votes

a simple method would be to use groups. Add your enemies to a group using the editor or with

enemy.add_to_group ( "enemies" )

then call elsewhere

var array_of_nodes = get_tree().get_nodes_in_group ( "enemies" )
by (4,058 points)

But is there a way to get an area node from said groups?

Any node can be put in groups.
But maybe i dont understand correctly what your asking.

You can loop through the array that Klaas has given you and do what you like with it.

for _i in array_of_nodes:
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 Frequently asked questions and 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 [email protected] with your username.