• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker [SOLVED] Depth Issue

Neptune

Member
I think something with depth was changed in the new GM:S 2 update, however I didn't see it in the patch notes.
I believe this, because my code was working great, and now its like it has a different functionality.

That being said, I'm having an issue with objects that are created at the same depth, like -1.
If the objects are all created on the depth -1, and are slightly overlapping, then the objects that have the lowest 'Y' origin value are taking depth priority, and are drawn on top of the rest (which in an rpg-view, is not what you want ever).

Strangely, this was working oppositely before today, the objects with lowest 'Y' origin values were drawn below the higher 'Y' origin values.

Here is a short clip of the code working properly. However, now it is all sorts of bad.

Any ideas or information on what might've happened is appreciated.
 

TheouAegis

Member
Are you sure it's the object with the lowest y-position and not the object with the lowest object_index or id? Did you reorder your resource tree at all? Have each object draw its y-coordinate, object_index, and id (or id-1000000) above it, then verify it's not either of the other issues I stated.

I'm installing the update now, just to do my own tests later if I have time.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
This is not a bug. GMS2 like GMS1.4 does NOT guarantee the render order for instances on the same depth or layer. The reason we have layers and depth is so that you can set what order things are rendered in. If you rely on objects being rendered in a specific way ON THE SAME LAYER then you are using undocumented behaviour and that is not how it should be done.
 

Neptune

Member
Thank-you for replies. I suppose i will have to adapt in some way to still achieve my "tall grass" effect.

@TheouAegis I will pay more attention to the indexes when I get a chance to try to fix the issue -- if there is a connection between index and depth, maybe I can place the objects in the room in such an order that prevents any unwanted clipping.
 

gnysek

Member
In marketplace there's dungeon demo and it nicely show how this is solved. It adds instanced to ds_xxxx structures based by y position (from what I remember, y is a key of ds_map, then as value there is a list of objects), and then draw in one batch, using for-loop.
 
L

Laurent57

Guest
Hi! Can you just change the depth in real time based on y?
 

Neptune

Member
I'm going to mark as solved. Here is the temporary fix I'm using for the grass objects:
Code:
if o_player_parent.y > y+5
{
    depth = 70000 - y;
}
else {depth = -y;}
This works well if the objects are offset by 1 pixel repeating and the room height is < 70000... so +1,-1+1---

Thanks for all the replies.
 
Top