0 votes

I have several nodes in a group and I want to delete them by code only those that are within that group, i know how delete childrens with:

 for i in get_children():

How do I do them for the nodes that belong to the group?

in Engine by (195 points)

2 Answers

0 votes

You can check if the node is inside the group with this method: Node.is_in_group

by (92 points)
+3 votes

You could do something like:

for node in get_tree().get_nodes_in_group("enemies"):
    // do something with this enemy node
by (16,798 points)
edited 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 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.