Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Overlapping Tile

Discussion in '2D' started by dlange83, Sep 30, 2018.

  1. dlange83


    Sep 5, 2018
    I'm new to unity and just starting to play around with the Tilemap feature. I've very quickly run into some visual bugginess.

    To experiment a little I added three tiles: grass, dirt, and a tree. The tree is a bit larger than a standard tile and is intended to overlap the tile above it to simulate perspective (Using Sort Order: Top Left).

    The problem is that while it properly overlaps the grass tile at the top (and oddly enough even at the bottom), the dirt tile overlaps it on all sides, cropping off both the top and bottom and completely ruining the illusion of perspective. The tiles are identical in terms of settings and they aren't on different layers.

    What I also discovered is that this unwanted overlap only occurs if any tree tile(s) (not just those affected) are placed above the middle of the camera. The first attached image shows how it should look. It works because there are no trees in the upper part of the tilemap. The second shows what happens if I add a tree in the upper area. In both cases the trees look fine over top of the grass, but in the bottom image (with a tree added above) the dirt tile completely crops any trees it surrounds.

    I'm not sure if it has something to do with the camera, layers, Z position or is just a glitch but I'm curious if anyone else is running into similar issues. I thought this might just be a visual glitch in the Scene editor but it also appears in the Game view as well.

    Anyone run into similar issues? Any input is appreciated.

    Screen Shot 2018-09-29 at 6.49.12 PM.png Screen Shot 2018-09-29 at 6.49.01 PM.png
  2. eses


    Feb 26, 2013
    Hi @dlange83

    "The tiles are identical in terms of settings and they aren't on different layers."

    Sorry if I got this somehow wrong, I did read your post very quickly, but why not just add the prop style objects into another layer, which renders over base tiles? Like trees, big rocks, buildings etc.
  3. dlange83


    Sep 5, 2018
    eses, thanks. Yeah I thought of that and it's sort of a fix, but I've had the issue occur with tiles that would also be on the same layer.

    For example I created a new project and had the same issue with two tree and bush tiles I was using on a "Barriers" layer. Rather than overlap according to the Sort Order (Top Left) a bush placed behind (higher up on the tilemap) a tree would still overlap the top of the tree instead of appearing behind it.

    And again it had the weird side behavior of reversing this effect if I placed a bush tile in the upper part of the map.

    That last bit of weirdness is what makes me think it's either a bug or something to do with the camera. That randomness and inconsistency is what's confusing. But again, I'm new to unity and the tilemap so maybe I'm missing something, idk.

    I want to know how to fix this but I'm also curious to know why this is happening.
  4. PabloJMartinez


    Feb 7, 2013
    This is exactly my problem too. Is this intended, a bug or maybe I'm doing something wrong?
    Last edited: Oct 12, 2018
  5. rakkarage


    Feb 3, 2014
    if the tile is bigger then a normal tile and it looks like it is then make it two tiles and put each part on its own layer and then you can control the position of each part...

    her is a split brush editor that draws and erases two tiles at once each on different layers and offsets

    Code (CSharp):
    1. using UnityEditor;
    2. namespace UnityEngine.Tilemaps
    3. {
    4.     [CreateAssetMenu]
    5.     [CustomGridBrush(false, true, false, "Split Brush")]
    6.     public class SplitBrush : GridBrush
    7.     {
    8.         public TileBase Back;
    9.         public string BackName = "Back";
    10.         public Tilemap BackTilemap;
    11.         public Vector2Int BackOffset;
    12.         public TileBase Fore;
    13.         public string ForeName = "Fore";
    14.         public Tilemap ForeTilemap;
    15.         public Vector2Int ForeOffset;
    16.         public override void Paint(GridLayout gridLayout, GameObject brushTarget, Vector3Int position)
    17.         {
    18.             if (BackTilemap != null && ForeTilemap != null)
    19.             {
    20.                 var bp = new Vector3Int(position.x + BackOffset.x, position.y + BackOffset.y, position.z);
    21.                 BackTilemap.SetTile(bp, Back);
    22.                 BackTilemap.SetTransformMatrix(bp, Matrix4x4.identity);
    23.                 var fp = new Vector3Int(position.x + ForeOffset.x, position.y + ForeOffset.y, position.z);
    24.                 ForeTilemap.SetTile(fp, Fore);
    25.                 ForeTilemap.SetTransformMatrix(fp, Matrix4x4.identity);
    26.             }
    27.         }
    28.         public override void Erase(GridLayout gridLayout, GameObject brushTarget, Vector3Int position)
    29.         {
    30.             if (BackTilemap != null && ForeTilemap != null)
    31.             {
    32.                 var bp = new Vector3Int(position.x + BackOffset.x, position.y + BackOffset.y, position.z);
    33.                 BackTilemap.SetTile(bp, null);
    34.                 BackTilemap.SetTransformMatrix(bp, Matrix4x4.identity);
    35.                 var fp = new Vector3Int(position.x + ForeOffset.x, position.y + ForeOffset.y, position.z);
    36.                 ForeTilemap.SetTile(fp, null);
    37.                 ForeTilemap.SetTransformMatrix(fp, Matrix4x4.identity);
    38.             }
    39.         }
    40.     }
    41. }
    Code (CSharp):
    1. using System.Linq;
    2. using UnityEngine;
    3. using UnityEngine.Tilemaps;
    4. namespace UnityEditor
    5. {
    6.     [CustomEditor(typeof(SplitBrush))]
    7.     public class SplitBrushEditor : GridBrushInspector
    8.     {
    9.         private SplitBrush Brush => target as SplitBrush;
    10.         public override void PaintPreview(GridLayout gridLayout, GameObject brushTarget, Vector3Int position)
    11.         {
    12.             var b = Brush;
    13.             var maps = brushTarget?.transform.parent.GetComponentsInChildren<Tilemap>();
    14.             for (var i = 0; i < maps.Length; i++)
    15.             {
    16.                 var map = maps[i];
    17.                 var name =;
    18.                 if (name == b.BackName)
    19.                 {
    20.                     var p = new Vector3Int(position.x + b.BackOffset.x, position.y + b.BackOffset.y, position.z);
    21.                     map.SetEditorPreviewTile(p, b.Back);
    22.                     map.SetEditorPreviewTransformMatrix(p, Matrix4x4.identity);
    23.                     b.BackTilemap = map;
    24.                 }
    25.                 else if (name == b.ForeName)
    26.                 {
    27.                     var p = new Vector3Int(position.x + b.ForeOffset.x, position.y + b.ForeOffset.y, position.z);
    28.                     map.SetEditorPreviewTile(p, b.Fore);
    29.                     map.SetEditorPreviewTransformMatrix(p, Matrix4x4.identity);
    30.                     b.ForeTilemap = map;
    31.                 }
    32.             }
    33.         }
    34.         public override void ClearPreview()
    35.         {
    36.             var b = Brush;
    37.             if (b != null)
    38.             {
    39.                 if (b.BackTilemap != null)
    40.                     b.BackTilemap.ClearAllEditorPreviewTiles();
    41.                 if (b.ForeTilemap != null)
    42.                     b.ForeTilemap.ClearAllEditorPreviewTiles();
    43.             }
    44.         }
    45.         public override GameObject[] validTargets
    46.         {
    47.             get
    48.             {
    49.                 var brush = Brush;
    50.                 var list = from map in GameObject.FindObjectsOfType<Tilemap>()
    51.                            where ( == brush.BackName) || ( == brush.ForeName)
    52.                            select map.gameObject;
    53.                 return list.ToArray();
    54.             }
    55.         }
    56.     }
    57. }
  6. PabloJMartinez


    Feb 7, 2013
    Okay guys, this problem is solved in Unity 2018.3 beta, you just have to enable the "Individual" mode of the Tilemap Renderer :)
    Last edited: Oct 12, 2018
    Warlag and rakkarage like this.