How does GDevelop select one object from a group?


Here Images is an Object Group containing sprites named Image0, Image1, Image2 and so on. Some of the sprites are overlapping, and GDevelop always seems to select the “last” one alphabetically (not the first, or not the one with the highest z-order). This is good for me, but can I actually count on this?

More generally, which member of an Object Group is used by the action in this case:
Condition involving an Object Group | Action using the group name as an Object

GD will pick all of the matching objects but the text object will only show 1 object. You can verify how many objects are picked with the picked instance count and the object or group name or by adding a for each object.

image

Note: The 1st text action uses set, the 2nd one uses add.

I tested the picking order a while ago. I couldn’t find the post. As I recall it picks the objects starting with the object first added to the group list. It picks all of the matching instances in that object and then goes through the other objects. The text object though might display the last object in the list. Edit: I tested it and it seems like the text object shows the oldest instance in last object in the group list.

I had 2 of each object stacked on top of each other.
image image

1 Like