Godot - Remove from group
This is how to remove a node from a group using GDScript in Godot 4.
You can remove a node from a group using remove_from_group()
.remove_from_group()
has the following characteristics:
- Specify any group name as an argument
- If the node does not exist in the group, the process is ignored
remove_from_group("group_name")
To remove all nodes or individually checked nodes, iterate through the groups.
var group = get_tree().get_nodes_in_group("group_name")
for node in group:
node.remove_from_group("group_name")