How are elementes in a group listed?

Godot Version

4.2.2

Question

When you run get_nodes_in_group, in what order are the nodes in the list?

I couldn’t find this information on the guide on how to use Groups. I assume it’s probably on the order the nodes where added to the group, but would like to be sure.

I was revisiting a project that emulates a turn-based board game, so I wanted nodes in the group to activate separetely and in a predictable order (unlike what would happen with, say, call_group), but having to implement a system that keeps track of the order in wich nodes were created globaly seems like reinventing groups. I could simply add a system to let the player choose the order (wich is how those things often work in board games anyway), but I’d reather analyze all my options if possible

From the docs:

Note: To improve performance, the order of group names is not guaranteed and may vary between project runs. Therefore, do not rely on the group order.

If the order of nodes is important and you need to call them separately, you should implement an Array based system.

1 Like

Thank you, guess I missed that part from the docs

Seems that I’m gonna have to implement an array based system indeed.