Search Unity

Bug Issue with tilemap "Z as Y" sorting with other non tilemap gameobjects

Discussion in '2D' started by percyJones6786, Apr 11, 2023.

  1. percyJones6786

    percyJones6786

    Joined:
    Jul 2, 2015
    Posts:
    9
    UPDATE: I have created an incident ticket for the unity Team to take a look at it and it has been confirmed(Added link to bug ticket below). I have also created a GitHub repository showcasing the bug and several test cases if anyone else in this community wanted to take a look at it and help me find the error or if there is some kind of work around.

    [up-vote the ticket if you can]
    Unity Bug ticket: https://issuetracker.unity3d.com/is...ear-in-front-when-z-position-is-higher-than-0


    GitHub Repo: https://github.com/Zazzao/UnityBug_IN-38554


    ==========================================================

    Original Post:



    Hi,
    I am working on a Zelda-Like isometric game and I have having difficulties getting the player sprite to sort accordingly with the isometric tile map. The idea is that the player can move around as well as up and down in the elevation. I have done quite a bit of experimentation and I am at a loss at how to get this to work. I have generally ran into the two situations shown below

    Case 01
    upload_2023-4-11_9-59-2.png

    Case 02
    upload_2023-4-11_9-59-32.png

    and this is just for the basic "voxel" tiles. i have yet to even consider tile details like rubble or foilage.

    Things That I Have Tried To Adjust To get this to work
    • Custom axis sort
    • The z value of the tiles and player
    • The pivot points of the tile as well as the player
    • not using a tile map and instead using separate tile gameobjects
    • Sorting Groups
    • Sorting Layers


    I feel that there is just something fundamental that I am missing/overlooking as I feel that this is a pretty standard isometric game use case and I'm going to shout "of course" when somebody tells me.

    Thanks in advance for the advice

    EDIT: Unity version 2021.3.15f1
     
    Last edited: May 11, 2023
  2. percyJones6786

    percyJones6786

    Joined:
    Jul 2, 2015
    Posts:
    9
    @Sebille Looking at other forum post on this site you seem very knowledgeable on the subject of isometric tile sorting. any thoughts?
     
  3. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,514
    You've listed checking all the major things. My guess is some little setting is wrong somewhere. If I had to guess it's the transparency sort axis, but that's just a guess. Are you sure it's calculated correctly? (see first link below for how)

    There's an isometric tilemap starter kit over here: https://blog.unity.com/engine-platform/isometric-2d-environments-with-tilemap

    This official techdemo project should also have the correct settings: https://github.com/Unity-Technologies/2d-techdemos

    If worst comes to worst, you could use that as a template for your game. It should have the correct settings.
     
    percyJones6786 likes this.
  4. percyJones6786

    percyJones6786

    Joined:
    Jul 2, 2015
    Posts:
    9
    Thanks for the response @Lo-renzo,

    I actually have been using those as references for this endeavor (as well as many others lol) but I took another deep dive into those two to see if I had missed anything and, to me it at least, still appears that I have all of the correct settings.

    So I decided to try and use the projects themselves as a template to maybe reverse engineer it or find my mistake.

    First thing I noticed was that 2D_IsoTilemaps-master tilemap you could not ever go behind any tilemap tile so it was just standard sorting layer stacking. That does not help with my use case as the player will need to move behind, in front, and on top of tiles.

    Second thing was the Z as Y example in the 2d-techdemos-master appears to have the same issue that I was running into in my project [see image below]

    upload_2023-4-13_18-13-13.png

    still looking into the issue but so far no solution or work around. It may just be something that is currently outside of Unity's capabilities at the moment.
     
  5. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    ive never used isometric tilemaps but i have some experience in sorting normal tilemaps by z

    what does your scene look like if you switch it to 3d view?

    do the isometric tiles apear to be a flat plane when you rotate around them?

    if that is so I cant imagine how you could ever achieve a correct sorting with a graphic that expresses width, height and depth all at the same time and in spite of that is rendered in 3d as a single flat plane

    the key to correctly sort will only be found once you look at your scene in 3d space
     
  6. percyJones6786

    percyJones6786

    Joined:
    Jul 2, 2015
    Posts:
    9
    UPDATE: I submitted a bug request and it turns out that this is indeed a bug with the "isometric Z as Y" tilemap
     
    venediklee and Lo-renzo like this.
  7. percyJones6786

    percyJones6786

    Joined:
    Jul 2, 2015
    Posts:
    9
    UPDATE: As mentioned above I had created an incident ticket for the unity Team to take a look at it and it has been confirmed(Added link to bug ticket below). I have also created a GitHub repository showcasing the bug and several test cases if anyone else in this community wanted to take a look at it and help me find the error or if there is some kind of work around.

    Unity Bug ticket: https://issuetracker.unity3d.com/is...ear-in-front-when-z-position-is-higher-than-0


    GitHub Repo: https://github.com/Zazzao/UnityBug_IN-38554
     
    venediklee likes this.
  8. MaxwellTan

    MaxwellTan

    Unity Technologies

    Joined:
    Mar 3, 2022
    Posts:
    75
    Hi percyJones6786,
    thanks for the info,
    I wonder maybe you want to consider this alternative tool.
    To see if help to solve you issue

    https://assetstore.unity.com/packages/tools/sprite-management/isometric-2-5d-toolset-27851
    upload_2023-5-16_19-30-38.png
     
    percyJones6786 likes this.
  9. percyJones6786

    percyJones6786

    Joined:
    Jul 2, 2015
    Posts:
    9
  10. MaxwellTan

    MaxwellTan

    Unity Technologies

    Joined:
    Mar 3, 2022
    Posts:
    75
    Hi percyJones6786, there is a few reason due to the complexity of isometric, you may consider alternative tool.

    Firstly, why some part of your sprite is hidden underneath under ground floor. so each sprite we recommend that the pivot to be at the middle lower bottom of each sprite.
    upload_2023-5-17_11-18-35.png

    After setting up the pivot correctly the sprite will be on top of the ground level
    upload_2023-5-17_11-19-26.png

    Secondly, why certain part of the tree are merge together, the reason is for the custom y axis we recommend using 1.
    upload_2023-5-17_11-22-46.png
     

    Attached Files:

    Last edited: May 17, 2023
  11. MaxwellTan

    MaxwellTan

    Unity Technologies

    Joined:
    Mar 3, 2022
    Posts:
    75
    Thirdly, the tree was too large it will post a problem where the certain sprite object not able to appear in front or back correct.
    For the picture below you can see I set the PPU 64 of the sprite to be consistent with the rest of the sprite
    upload_2023-5-17_11-30-30.png

    Given all the this setting unfortunately it may not appear correctly in all cases. You may still run into issue.

    Therefore you want to consider alternative tool for the time being.
    https://assetstore.unity.com/packages/tools/sprite-management/isometric-2-5d-toolset-27851
     
    percyJones6786 likes this.
  12. percyJones6786

    percyJones6786

    Joined:
    Jul 2, 2015
    Posts:
    9
    Thanks @MaxwellTan for the in-depth analysis of this issue.

    This has been a “fun” challenge to work throught the isometric complexity of this project. I have done some quick preliminary check and the proposed changes look very promising. I will be doing some in-depth testing of these this weekend and I will let the forum know my findings. Just so we are on the same page you are suggesting the following:

    1: change the sprite sort to middle lower on each sprite

    Originally I had been lining up where the “feet” or “ground center” of where the obj would be resting on top of the tile, but you are suggesting that I shift the sort and use a parent obj to control where the feet are (ie line it up with the XY or tile that the player or obj is supposed to be in world space)

    Q1: does this include the tiles themselves or just object on the tilemap [I would think so but don’t want to assume]


    2: Change the Y on the custom axis sort setting from 0.5 to 1

    This seems very strait forward and seems that it will work in combination with the fix from number 1

    Q2: I have heard conflicting information on this from serval sources both inside and outside of Unity so any addition information you may have on the subject or the reasoning for 1 instead of 0.5 would be extremely helpfully


    3: change the tree to PPU 64 [Assumption – ensure that ALL assets are the same PPU, in this case 64]

    No notes – makes complete since, was trying to fake a large “multi-elevation” object for this test


    4: Use the suggested isometric 2.5d toolset to help with other issues that I may run into

    No notes, well give it a test run.