"cursor is on object" condition is not respecting z-order?

Hi, one of my objects has the behavior Ysort (the extension to set the z-order of each instance to its Y position). Visually, it works perfectly: if an instance is overlapping with another instance of the same object, you can see the one with a higher z-order on top.

The problem is when i try to interact with this object and use the condition “the cursor/touch is on object”. If two intances are overlapping, and I hover or click on them, the actions are executing for the instance with smaller z-order. I was expecting that it should recognise the instance with bigger z-order instead because if on top of the other.

is there something Im not understing correctly? or whats the proper way to make it work as I need it to?

Many thanks!

edit to clarify: All my objects’ origin point are set to be their center bottom

The “cursor on object” doesn’t care about Z order, it checks if the cursor overlaps with the object, whether visible or not. Modifying your origin point may move the object’s boundaries, try to use the debug view (you can enable it with an action) to visualize the bounds of your object.

1 Like

I see, thanks for the answer.
unfortunetly for me, modifying the origin point wont solve the problem, because some objects walk around and sometimes are going to overlap with another. If they were static I can manually make sure they dont overlap, but when they move is a bit difficult. Thanks anyway, i’ll accomodate the events so they never overlap or so.

When you have mouse over 2 instances of an object, GDevelop creates a list of them. If you just reference the object by name, it’ll be the first instance in the list.

You’ll need to add a repeat for each object as a subevent of the cursor over event, and then use further sub-subevents to determine the object with the highest z-order.

1 Like

nice idea, MrMen, ill try this. thanks!