• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Clicking top object – default behavior in GMS2 with manual depth?


When u want to click top object and did not set depth of those objects the top object will not be clicked but actually the clicked object will be the first one placed in the room. But when you set depth each of those objects manually the object with the lowest depth will always be clicked.

I need to know is this the default behavior in GMS2, so no other solutions (except setting depth manually) for clicking top objects are necessary? Thank You

If u need more explanation I made simple project and below is a screenshot of what I’m talking about:
GMS2 top click.jpg
Same project. Top image = squares depth set automatically by GMS2 (all squares have depth = 0, why?). Bottom image = squares depth set in each object manually by me from 4 to 1.

for top clicked obj_click has this basic code in step event:
if mouse_check_button_pressed(mb_left) {
    ins_top_clicked = instance_position(mouse_x, mouse_y, all);
    if (ins_top_clicked != noone) {
        with (all) clicked = false;
        ins_top_clicked.clicked = true;      
    else with (all) clicked = false;
each colorful object has basic code in step event:
if clicked image_index = 1; // with yellow outline
else image_index = 0; // without outline
Last edited: