Problem with Collisions Overlapping Objects

How do I…

Screen Shot 2022-11-23 at 18.06.41

Im trying to work out those “red X buttons” that are created over other multiple clickable objects…

Watching the image: I want to Mouse click (to execute code) over the “X Button” but because it is created on top of other clickable objects (Floor Tiles with other codes) the collision detects all the overlapping objects [ (button X) and (Behind layers) ] and Click and execute all code of both of them (Button and Tiles).

That is a problem for me because the “X button” has a code “On Mouse Click” ( That I need to execute alone) and the “behind Floor Tile” has another code “On Mouse Click” That I want to ignore because is behind. (All items are on the same layer and Layout atm).

-Is there a way to ignore behind objects collision? And Just take into consideration collision from the top view object (X button)

I, ve been some days researching but have not had success. Many Thanks.

Yeh lots of different solutions but hard to say without knowing specifics of what you’re doing. If the floors code doesn’t need to be run at all when the red x is visible you can just set it not being visible as a condition of the floor code. But if the floor code does need to run while the x is visible but just not when the x is being pressed maybe just add a condition to the floor code of not being in collision with the red x to run.

Many Thanks Lucky for your answer…
“But if the floor code does need to run while the x is visible but just not when the x is being pressed maybe just add a condition to the floor code of not being in collision with the red x to run.”
I will be thinking how to develop that idea. I do not know atm how to tell Gdevelop “is not in collision”
:slight_smile:

Hi Efebe and welcome, I had a similar problem to you. I used a community extension by Arthuro555 called Object picking tools. You can use it to select the object with the highers z order. It made my life a lot easier.

Many thanks for your Advice Bubble… I,ve tried different approaches abd also use Object Picking tools… But I not had good results with it yet.
Thanks :slight_smile:

Many Thanks Lucky Super clear, Tonight I will be tryning this method.
So good that u even made a test with screenshots :slight_smile: Apprecciate a lot thanks :slight_smile:

1 Like

If that doesn’t work you can try this. It’s inspired from the Gdevelop example City Builder, how the brush tool is set to not brush the background if the player is selecting a brush.

Hi again Efebe, you’ve got a few other things to try now but if you go back to the object picking tools extension, here’s how I used it.

This is what’s meant to happen, I click on the shape and it gets an outline effect to show it’s selected.
So in the first sub event I tell it to NOT enable any border outlines on the shapes it’s touching.
Then in the next sub event I tell it to pick the shape with the highest z order and enable the border effect on that one.

Hello Bubble. Many thanks for this Tip :slight_smile: The option “Pick The higest ZOrder” is a good one… Althought I need to investigate and try hard because Im on a simulated Isometric space and a lot of Zorder is going on…
Im working on the problem… Seems that it works well now… Without any order Z picking, or any collision on mouse, or any extra variables… I cannot tell you why right now… Just need to investigate further.
Many thanks :wink:

Thanks for the tip… I really hate to add variables all time :smiley: because I get lose on the code… But defenetly a scene Variable fix well this problems.
Many Thanks.
I build again all code and seems that it works well without variables and extra stuff… But need to investigate why to tell you the solution.
Many thanks.