• 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!

Windows Why not 'depth = y * -1' ?

Erayd

Member
Exactly as the title says. I keep seeing people say not to use this for x, y and z but I don't quite understand. I'm working on changing how depth works in my game and currently this is what I have as I started the project on the old studio. It has a couple weird issues/quirks, but it generally works. Why shouldn't I use it and why should I use one thing over another? What are the big draws/benefits of the new layer system and whats the point in having depth in the system at all if it seems like it is discouraged from using it in the way I used to?

I imagine I am just massively confusing myself and just not following, so any guidance or corrections on this the better!
 

Erayd

Member
I use it specifically for sprites/objects in layers, but I don't really even use layers. I just set a depth and some of the objects dynamically set their own depth with the -1 algorithm. Not sure what you mean by the returns -1 thing. Haven't come across an issue yet.
 

Joe Ellis

Member
I think it returns -1 when you get the depth from a tile layer that's been modified, but if you're not using layers I wouldn't worry about that
 

mimusic

Member
From my understanding, because there now has to be a layer existing for every depth actively being used, either pre-defined or dynamic/temporary, there's more overhead that comes with reassigning depth. You're no longer just changing the depth, but also the layer associated with that depth. I don't entirely understand what data goes into a layer, however, so I'm not exactly sure what impact of this operation is. I remember I used to see around that depth = -y is significantly slower on the layer system, however. If you take a hard look at your performance and don't see a difference between having depth = -y on or off, you're probably good to keep on with what you're doing. Just be wary of the issues that may arise if your project gets larger and more things are sorting themselves with "depth = -y".
 

Neptune

Member
I've been using GMS2 for about a year, and for the most part... its great.
The layers work well in the Room Editor, but as for depth -- i 99% of the time still use instance_create_depth (apposed to instance_create_layer).
(Most of my objects are depth 0, and are rendered in order respective to their y coordinate -- this has been working very well).

This render/sorting approach is more or less
Code:
depth= -y;
I havn't done much with tiles other than referencing their data, so I'm not sure what issues are there...
 

Erayd

Member
I decided to stop thinking about it and have since dived deep in to the world of draw ordering by just using depth. Makes my life so much easier and has allowed me to create a few shaders to make a few things visually make more sense. Meaning now that I don't have to think about it because depth is simple, I can spend my energy on the fancy stuff. And it just works. That's what matters most, it works.
 

T2008

Member
I have this same problem. Could you please give me an example of what you're doing now? For example, in the player object step event, i have depth = -y-sprite_height. How would I do this for layer?
 
Top