[SOLVED] Pick item with higher z-order

What is the simplest way to pick ONLY the object with higher z-order when the mouse/cursor/touch is over a bunch of objects?

The object picking tools extension has an option to pick the object with the highest z order.

1 Like

Really? I didn’t know! I’ll check it out immediately!
Thanks.
But really… it should be a simple Condition.

I have seen the extension but it just pick the “higher” instance of the same object!
I needed something that pick the “higher” instance of different (or equal) objects touched by a cursor/mouse/touch!

Put all the objects in an object group and reference the group rather than a specific object.

1 Like

Have you tried adding all the objects you want picked to an object group and then passing that object group to the “pick object with highest zOrder” action?

1 Like

Not really. GDevelop should be providing base functionality that developers use to construct more intricate or specific actions. So in this case, GDevelop has the ability to iterate over objects, inspect object properties, set variables, compare numbers etc. The developer can use these to create a program flow to do what they’re after.

It’s the same for any programming language - you’re given a set of basic commands that can be combined to create complex functionality.

I can confirm, weadsy1 and MrMen are correct. The object picking extension explicitly has an action to pick the highest (or lowest) zOrder and it works for this (I use the extension pretty heavily and can confirm it functions well).

image
Both conditions and actions exist for this from the extension. You will need to follow the guidance above and add the objects you want to pick from into an object group (if there are multiple types of objects. If everything is just instances of one object, then you’re fine already.)

1 Like