Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

What the heck is going on with Unity Tilemap sorting? One of my Tilemaps pokes through the other.

Discussion in '2D' started by FrickinSilly, Nov 20, 2022.

  1. FrickinSilly

    FrickinSilly

    Joined:
    Feb 19, 2020
    Posts:
    53
    I have two tilemaps. The tilemap rendererd are both in the same Sorting Layer, but have different Sort orders (500 and 1000 respectively).

    Yet for some reason, the spikes poke through the other tilemap in the editor. What's going on here? I've taken a video/gif to demonstrate.

    https://imgur.com/a/heiOP90

    Also:
    - Z position is 0 for all GameObjects
    - This occurs in Scene view (after pressing 'F' on either of the tilemaps) AND in the Game itself.
     
  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,503
    Anything improve if you put the sprites in the same Sprite Atlas? (won't work in Scene view)

    Your problem seems similar to this one: https://forum.unity.com/threads/tilemap-flickering.924167/

    They recommend trying a small z-offset. Some other suggestions in there. If that doesn't work, it could be a bug.
     
  3. FrickinSilly

    FrickinSilly

    Joined:
    Feb 19, 2020
    Posts:
    53
    Weirdly, changing the z-offset doesn't fix it.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    Here's why:

    Three (3) primary ways that Unity draws / stacks / sorts / layers / overlays stuff:

    https://forum.unity.com/threads/orthographic-camera-rendering-order.1114078/#post-7167037

    In short,

    1. The default 3D Renderers draw stuff according to Z depth - distance from camera.

    2. SpriteRenderers draw according to their Sorting Layer and Sorting Depth properties

    3. UI Canvas Renderers draw in linear transform sequence, like a stack of papers

    If you find that you need to mix and match items using these different ways of rendering, and have them appear in ways they are not initially designed for, you need to:

    - identify what you are using
    - search online for the combination of things you are doing and how to to achieve what you want.

    There may be more than one solution to try.

    Additional reading in the official docs:

    https://docs.unity3d.com/Manual/2DSorting.html

    And SortingGroups can also be extremely helpful in certain circumstances:

    https://docs.unity3d.com/Manual/class-SortingGroup.html
     
  5. FrickinSilly

    FrickinSilly

    Joined:
    Feb 19, 2020
    Posts:
    53
    In this case, those facts are irrelevant. Two tile instances on the same tilemap are being rendered around a tile that has a different sorting depth. It makes NO sense based on the official docs
     
  6. flasker

    flasker

    Joined:
    Aug 5, 2022
    Posts:
    193
    on detect chunk culling bounds change to manual

    change the Z on chunk culling bounds to like 50, if doesnt work increase even more until fixed

    do this on both tilemap
     
  7. FrickinSilly

    FrickinSilly

    Joined:
    Feb 19, 2020
    Posts:
    53
    I may have to wait until the weekend to try this out, but I'll give it a shot. For now, I'm trying to understand from the documentation what this does and what the significance of the number 50 is.
     
  8. flasker

    flasker

    Joined:
    Aug 5, 2022
    Posts:
    193
    good luck
     
  9. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Hi, could you file a bug with your project using the Unity Bug Reporter and post the case number here? Thanks!