+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 (823 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 (823 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 https://godotengine.org/asset-library/asset/3

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 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 webmaster@godotengine.org with your username.