+1 vote

Hi all,

I have a large number of sprites They're instanced into my level scene. As I added them to the level scene, I added each one to a group, called "bricks".

So as it stands, I have a level, there are about 300 of these sprites and they are all in the "bricks" group.

I want to parse through each "brick", retrieve its statistics and do specific work on each one.

Everywhere I look when researching a solution is groups and in particular is_in_group().
The problem is I can only find the ability to use this if there is a collision. For example: body.is_in_group("group name") comes up a lot. I'm not using collisions though.

Is there a way to parse over the items in my "bricks" group without collisions happening? It MUST be something simple but I've spent an hour looking and have had no luck.

Any advice would be really appreciated.

in Engine by (810 points)

.... and I think I found it!

var bricks = get_tree().get_nodes_in_group("bricks")
    for i in bricks:
        #do stuff

Will report back...

check call_group too, may be better or not, depending on the "do stuff" part.

1 Answer

+3 votes
Best answer

Answering for completeness...

var bricks = get_tree().get_nodes_in_group("bricks")
    for i in bricks:
        #do stuff
by (810 points)
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.

Categories