This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

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.

in Engine by (838 points)

1 Answer

+1 vote
Best answer

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.

by (838 points)

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

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.