This is my first try making a "proper" game in Unity. I'm using the latest version (2019.2.2 at the time of writing) and I'm writing with C#. This is a project I'm doing for my studies, together with another person (he makes tiles, sound, music and I'm at charge of the programming).

We are making a 2D Roguelike RPG using the Unity tilemap feature.

My algorithm to generate dungeons works really well, but only used one ground tile and one wall tile. We found that to be very boring and changed it.

Now comes the problem. If I let the algorithm pick between fewer than 3 tiles, everything works fine.

Example of how it should work

If I let the algorithm pick from more than 2 tiles, something strange happens and the some tiles don't overlap properly.

Example of how It shouldn't work

I hope somebody can help me understand why this happens.

Here the important settings of camera and tilemap:

  1. Camera
    Settings of the camera
  2. Grid
    Settings of the grid
  3. GroundLayer
    Settings of the First Tilemap
  4. WallLayer
    Settings of the Second Tilemap

One weird think I have been able to find out: The tiles that don't overlap will change if I change the position of the camera.

As a gif:

Zooming into the map, the dark, incorrectly-overlapped walls occur in different positions

  • \$\begingroup\$ Do I understand correctly that your wall tile sprites extend beyond the bounds of the square tile they represent, and up into the space occupied by the tile above, and you're relying on these tiles to be drawn later than/over the tile above to get the appearance that you want? If so, this probably isn't a code issue (and posting all your code is not an appropriate use of this site anyway) - what you should walk us through instead is your configuration of your tilemap's rendering mode and packing settings on your sprites. \$\endgroup\$
    – DMGregory
    Aug 24, 2019 at 19:04
  • \$\begingroup\$ @DMGregory Should I remove the code then? Sry for posting It then. Yes, the walltiles are 32x64 and reach over the tile above them. The ground tiles are 32x32 \$\endgroup\$ Aug 24, 2019 at 19:10
  • \$\begingroup\$ Up to you - it's does not look like it's required to solve this problem, so I'd say it distracts from the question. Generally we ask users to do the work of boiling their problem down to a "minimal complete verifiable example" - the least code & scene/project setup instructions we'd need to reproduce the problem in a new project. So if your dungeon generator algorithm isn't the problem, we don't need that code. You can reproduce the same problem by painting with these tiles on a tilemap with no scripts at all. \$\endgroup\$
    – DMGregory
    Aug 24, 2019 at 19:17
  • \$\begingroup\$ Made the changed, removed the code so the post dont gets to hugh. \$\endgroup\$ Aug 24, 2019 at 19:41
  • \$\begingroup\$ I see you're rendering in chunk mode. Did you try packing your sprites into an atlas as recommended at the link I posted above, and testing the result in play mode? \$\endgroup\$
    – DMGregory
    Aug 24, 2019 at 19:47

1 Answer 1


"Pack all the individual Sprites that make up the Tilemap into a single Sprite Atlas to solve this issue. To do this:

  1. Create a Sprite Atlas from the Assets menu (go to: Atlas > Create > Sprite Atlas).
  2. Add the Sprites to the Sprite Atlas by dragging them to the Objects for Packing list in the Atlas’ Inspector window.
  3. Click Pack Preview. Unity packs the Sprites into the Sprite Atlas during Play mode, and correctly sorts and renders them. This is only visible in the Editor during Play"

This solved my problem. https://docs.unity3d.com/Manual/Tilemap-Isometric-RenderModes.html


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .