Can anyone see why this queue_free() is deleting my complete scene?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Robster
:warning: Old Version Published before Godot 3 was released.

I have a tree somewhat like this:

Root (script here)
- lots
- of
- other
- nodes
- here
-- HBoxContainer
--- lifeIndicator
--- lifeIndicator
--- lifeIndicator

The lifeIndicator nodes are in a group called lifeIndicators

This is the function I’m using to remove them:

func removeLifeIndicators():
	var indicators = get_tree().get_nodes_in_group("lifeIndicators")
	for i in indicators:
		if i != null:

The good news is, it removes them. The bad news is it removes EVERYTHING so that all that’s left is the Root node. Everything else is gone.

How can that possibly be? It must be something simple but I just can’t see it.

:bust_in_silhouette: Reply From: Robster

My bad and I’ll leave this here if it helps someone in the future.

When I was adding my lifeIndicators to the group, I was doing this:


when I should have been doing this:


It wasn’t the code in the opening question, it was the code here. I hope that helps.

Groups are really good but the lack of group management sometimes makes it a problem, you can try this addon to help to organize Group Manager - Godot Asset Library

eons | 2017-04-25 17:11