My Z-Order is not working

How do I fix my Z order issue?

The expected result I am trying to create is depth for a 2d RPG style game and am trying to connect the Z order to the Y value so the player can appear behind an object when the Y value is larger than it, and in front when the Y value is less than it.

After following 6 tutorials, and messing around with it myself I can’t fix the issue. The player keeps staying behind to object and never in front. If I didn’t do anything to the Z order it would constantly stay in front of the object. I even tried Setting the players z order to the objects z order +1 when colliding with it, and that didnt work either.

Please help in any way possible. I’ve been trying to learn Gdevelop for a week now, honing a single skill every day for 30 minutes and I’d hate to waste all my effort just to start over and relearn.

Hello and welcome.

Your condition isn’t working because you are setting the object’s z-order to the player z-order + 1.

You can run an unconditioned event like this

and it will mostly work depending on how far down the screen the table is. If the table is pretty high up, you could run that condition and change the origin point of the girl to the bottom instead of top left. Just go in to Edit Points in the object editor.

There is also an extension called Y-Sort that does the same thing only as a behavior you can add to each thing you want it on.

Or you can just use the condition you show in your image, but instead of changing the table z-order set to girl z-order + 1, set it to girl z-order -1.

Hi Mark, this is great, very inspiring, I have many many knowledge gaps. I’ll try harder now. Thank you!

Do as @Lucky-j has suggested and use the Y-Sort extension. It’ll need to be added as a behaviour to every object that the player can move in front of and behind, as well as the player object itself. But it does all the work for you.

And move the origin of your objects to near the bottom of each sprite. If the origin is in the top left, then the move behind and in front doesn’t work if objects are different heights.

I did try setting it to girl without the +1 and just Y() but it didnt work sadly. Im going to try the Y-sort behavior. Thank you so much for the help.

I’m glad to inspire someone! I wish you very well with your work.

1 Like

Im gonna try the y-sort behavior. Thanks for the note on the origin points, I accidentally forgot it on a few different objects.

Hi, I’m having the same problem. I’ve downloaded the Y-Sort behavior and added it to all of my terrain, and my character. The problem I’m having, is that it literally only works for one object. I’ve got the points at the bottom of my object and character, like its says in the Gdevelop Top Down Rpg video. It still does not work, any tips you have?

Are all of the objects on the same layer?