How would I handle layering in my game when the player sprite is taller than the tiles on my map?

Hello everyone,

While creating my RPG-like game, I started wondering how I would handle layering in my game to make it look like the player is walking behind or in front of certain objects. To clarify my question, have a look at the image below:

I found this image on Discord and is not mine. Still, this is an example of what I want to avoid with my own game, which works in a similar way. The player is expected to be in front of the fence, and not partially behind it.

Does anyone have a way to fix this problem? Help would be really appreciated!

Are u using your own code or extended? If it’s your own draw the tiles in rows starting from the top and finishing at the location of your player.
Then. Draw your player followed by the rest of the tiles

This is not a problem, MG has a “layer depth” parameter option for drawing 2D sprite.

I am aware of the LayerDepth parameter, and I am using this. But my question is what the best way is to display the player both behind and in front of the player when needed.

I use the feet position of every object as the Layer depth you
can just use Position.Y+Height of the sprite as the Layer depth.

2 Likes

Sounds good. Can I just do this with every single object and expect it to work? Like the player, all the tiles, other objects, etc?

Sure, I’ve use this kind of technique as showned below, I’m pretty sure it will work on any game framework/engine.