Unity 2.5D Tilemap Depth

Hello, Gahwon here. Here’s another Unity tutorial!

Have you ever tried to make a 2.5D world, only to realize that your trees are rendering behind the player all the time? Well, fear not!

Although many sources exist on creating this feature using sprites, this tutorial instead uses the new Unity Tilemap to apply depth.

For those who want the whole source code, here it is.


Feel free to use this anywhere (probably not the sprites since I drew them and I’m not an artist).

Here’s a TL;DR version of the system: Each tile contains a height property. This height is compared with the player’s height every frame to see if the tile should overlap or not. Overlapping tiles are moved to a new Tilemap layer that is always rendered in front of the player. This layer is cleared at the start of every frame.

Continue reading