Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Isometric Tilemap Sorting issues

Discussion in '2018.3 Beta' started by GoldenSkullArt, Sep 13, 2018.

  1. GoldenSkullArt

    GoldenSkullArt

    Joined:
    Aug 14, 2013
    Posts:
    49
    Hello folks,

    first of all hearing that you are adding isometric tilemaps was great news.

    When I use different Tiles, they seem to be sorted in a strange way by Tile ID and not by their y-value on-screen(or in the tilemap for that matter). For instance the dirt always appears behind the grass tiles, no matter where they get placed. I have tried all things I could imagine and have not moved closer to solving this, so my assumption is that I am either missing some setting, did the setup wrong by not knowing some internal mechanisms or the sorting is somewhat broken.

    What I expect to happen is basically this:

    (taken from your blogpost)

    but what I am actually getting looks like this:



    Maybe one of you can point me to the proper settings or can back up my experience, so we can figure out whats going on and find ways to fix it.

    Thanks
     
    g3nuine3 and jeanpoolay like this.
  2. Sebille

    Sebille

    Unity Technologies

    Joined:
    Jul 23, 2018
    Posts:
    5
    Hey Max!

    So the issues you are having are due to two things that aren't necessarily clear even if you've worked with normal Tilemaps before - Isometric Tilemaps are still quite new so not all specifics of working with them have necessarily been explained or covered (we're working on it!).

    First of all, in order to ensure the tiles get sorted by the Y-value, you need to go into Edit > Settings > Graphics, and change the Transparency Sort Mode to be Custom Axis, and change it from Z-sorted to Y-sorted by setting the values to 0,1,0 for XYZ respectively:

    upload_2018-9-13_16-23-24.png

    The second thing you might need to take a look at is the rendering mode on your Tilemap Game Object. Within the Tilemap Renderer component, you will find that the default mode is set to Chunk. Chunk mode basically batch-renders the tiles, however for them to be sorted properly, the individual textures need to be packed into the same Sprite Atlas (Assets > Create > Sprite Atlas, then in the Inspector add the tile textures you wish to pack to the list). After you do that, when you go into the Game View the tiles will be layered correctly. It is important to note however that this is not currently supported in the Scene view, so what I would recommend is - change your rendering mode to be Individual while you are editing; then once you have your level's structure finalized, you can change it back to Chunk for when you build your project.

    upload_2018-9-13_16-23-50.png

    Let me know if that works :)
     
  3. GoldenSkullArt

    GoldenSkullArt

    Joined:
    Aug 14, 2013
    Posts:
    49
    Hello Aliceh,

    thank you so much for your swift reply.

    I tested it and it works! Thank you so much. I am looking forward to playing around with this more.
    Thank you for your assistance in this matter.

    Here is the same screenshot from before but with the fixes.


    Keep on doing great stuff folks! :)
    <3
     
    GarthSmith likes this.
  4. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
    So no sprite atlas, no sorting ?
     
  5. Sebille

    Sebille

    Unity Technologies

    Joined:
    Jul 23, 2018
    Posts:
    5
    If you are using Chunk mode, then no. For Individual rendering mode, whether they are in an atlas is irrelevant, so they will get sorted correctly. The reason Chunk mode does not sort individual assets correctly is that they come from different textures and therefore cannot be batch-rendered. As such, I would recommend packing your textures into a Sprite Atlas (in other words, a single texture) and rendering in Chunk mode, because it gives you better performance.
     
  6. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
    Ok thanks for the explanation
     
  7. SirStompsalot

    SirStompsalot

    Joined:
    Sep 28, 2013
    Posts:
    112
  8. zulfajuniadi

    zulfajuniadi

    Joined:
    Nov 18, 2017
    Posts:
    117
  9. Corvwyn

    Corvwyn

    Joined:
    Nov 15, 2013
    Posts:
    114
    Does anyone know how to use the Custom Axis Sort feature in the Lightweight render pipeline?
     
    Lorefold and mikapote like this.
  10. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
    @Sebille How do you managed character order with @zulfajuniadi's scene ? because the character will not be in tilemap, isn't it ?
     
    NoobCoderFake likes this.
  11. zulfajuniadi

    zulfajuniadi

    Joined:
    Nov 18, 2017
    Posts:
    117
    I would also be interested to know
     
    NoobCoderFake likes this.
  12. GoldenSkullArt

    GoldenSkullArt

    Joined:
    Aug 14, 2013
    Posts:
    49
    Hello,

    I had some more time to dive into this wonderful new feature, so far I love it, it has great potential to be something really amazing, the groundwork done so far seems solid.
    After I made a script that converts sprites and spritesheets into tiles, the workflow is now quite nice (if anybody is interested, its downloadable in the pins of the unity channel in my discord [Link])

    Okay, I have done some more testing and for some reason the "Z Position" feature doesn't do what I'd expect, no matter with which setup I use it and whether the z-Position is negative or positive, the result is the same with this setup



    Here is an example picture of this image. What I am trying to do is to make "Walls" by changing the z-position without the need to always make a new tilemap for each and every new "layer" I need, I kinda expected the z-position to take care of that. I tried it with Isometric and Isometric Z to Y, the result is the same, there is no way to put a tile "higher" (on screen and in the isometric world) and have it appear in front of the lower tile.

    Am I again missing any setting/feature? Or is this intentional? Is this something you plan on having it working?

    As soon as I am through with my evaluation for environment building, I will try to play around with Character setup.

    Hope you all had a wonderful weekend.
    Much love <3
     
    Sylmerria likes this.
  13. GoldenSkullArt

    GoldenSkullArt

    Joined:
    Aug 14, 2013
    Posts:
    49
    @Sebille or anybody else..Is there any Info on how to get the "Z-Sorting" to work with this setup?
    For instance to make Wall tiles in the same Tilemap that are "higher" on-screen (Y axis) but should be rendered in front of the object with lower z. (See example image I posted earlier)

    Because by setting the Y-Sorting in the graphics, it automatically sorts everything with a higher Y value behind all other tiles in the tilemap. While this is great for ground-layers, it completely hinders the placement of any walls or anything. Is this intentional? Should every height-layer be on its own tilemap or will you add additional implementation of the Z-Sorting?
     
  14. Sebille

    Sebille

    Unity Technologies

    Joined:
    Jul 23, 2018
    Posts:
    5
    Hey guys! Sorry for the delayed response - I've been looking into the stuff y'all asked about and wanted to make sure I didn't misinform you. It's nice to see so many of you trying out Isometric Tilemaps already!

    Firstly, regarding the character sorting with Tilemap (@lenneth78 and @zulfajuniadi) - it's actually pretty easy. So long as your detail level/higher ground level tiles and your character are on the same sorting layer, if you make sure that your detail layer has the same sort order as your character (e.g. if your ground is 0 and your detail is 1, then your character would also be 1), the character goes behind and in front of objects on said detail layer as expected (provided you are sorting by Y as described before):



    As to the issue you are having @MaxHey - I don't know whether whether the kind of same-layer Z-axis sorting you are looking for is possible at the moment - the feature is still in preview however so everything is subject to change. Let me ask the 2D team and find this out for you. I can definitely see why this sort of workflow would be wanted for levels that wouldn't specifically have even heights, so this is good feedback!

    For now, the alternative solution that I would propose for this is that you create a new Tilemap layer on the same grid for each of your height levels. You can then change the layer sort order to be higher, and increase the Z value on your brush to paint tiles that appear to be higher than those on the level below. To my knowledge, changing the Z value on the brush only works for Z as Y Tilemaps, but you can also simulate different height levels with normal Tilemaps by changing the tile anchor position (personally I find Z as Y Tilemaps to have a more intuitive workflow but both solutions are viable). Sorry I can't help you with the exact thing you're looking for right now, but I'll definitely investigate this further. Let me know if this helps for now and if you need any more info on the topic.

    @Corvwyn - I will also ping the 2D team with your question and get back to you ASAP!
     
  15. beanie4now

    beanie4now

    Joined:
    Apr 22, 2018
    Posts:
    311
    This is all very very helpful. Wish I would have read this thread before wasting half a day...
     
  16. GoldenSkullArt

    GoldenSkullArt

    Joined:
    Aug 14, 2013
    Posts:
    49
    @Sebille Thanks for the thorough reply. As well as for the example and explanation of the character.

    Yea, I assumed it might not be possible at the current moment. It would be great if you could find out more. Because having played with it for some time, it became apparent that creating a new tilemap on a different sorting layer takes quite a bunch of steps to make, clutters the hierarchy a bit. I personally would love to make use of the z-positioning that seems to be already there, to have an additional way to sort the tiles inside one tilemap.
    EDIT: Just saw the gif you posted on twitter [Link] - how do you switch between different heights so quickly? Did you setup different grids for different heights before or am I missing some shortcuts? :D

    I am thinking for use-cases where I would want to build a house or a high structure like a church with tiles for instance (as the ones from my 2D isometric village pack)...imagining that I need to have each layer in its own tilemap and switch through them as I work sounds a bit counter-intuitive for me at the moment.

    I would really love to have some sort of option (possibly in the non z-to-y mode) to use the z-value to also sort tiles in a way. This could also be done by giving the tiles actual z-offset (I saw in the editor, they are all flat on one layer), and then add the Z-Axis in the custom sorting settings so have both work at the same time?

    So far I have achieved walls by having two tilemaps and giving the second one a higher sorting order and then change the anchor position.

    In the Z as Y Tilemaps, I was a bit surprised to see that if I stay at the same grid position and change the Z, it jumps behind the tiles but as they are sorted by their Y value, it does make sense...if somehow the Z could also be taken into account (then the tiles would need to have an offset or somehow tell the render engine that they have an internal z value that they can be sorted with? no idea how deep the rabbit hole goes what could be achieved by writing depth or idk...). I understand its a rather complex issue since those 2D tilemaps are probably supposed to be as flat as a pancake.

    If somehow possible, they could be non-flat, then that would be an easy fix to allow for any z-offset.

    If otherwise possible the tilemaps could also support a 3D coordinate system setup, where the tiles are placed according to their x-y-z position in the 3d coordinate system, each tile would need to be rotated (x:30,y:45) but this setup would also allow for the tilemap feature to be intertwined with setting up tile-based 2.5D/3D maps
    As in this example:

    In this example, the 2D tiles are setup in the 3D coordinate system and rotated towards the camera. With this setup, even navmeshes could be used and the tiles could easily be replaced with 3D prefabs as well.

    I am not sure how flexible the tilemap system is but it would surely be cool if it could support this setup. :)
    If not, thats also fine its a great too so far.

    In any case: Keep up the great work Unity Team.

    Much love <3
     
  17. zulfajuniadi

    zulfajuniadi

    Joined:
    Nov 18, 2017
    Posts:
    117
    Thanks @Sebille, yep got that working.

    Setting the Grid to Isometric Z as Y did the trick for me. Not sure why you it's not working for you. Though I suspect our implementation might be a bit different.

    This is an infinite terrain I built with the new isometric tilemap:



    And this is with the Grid set to Isometric only:

     
    Last edited: Sep 19, 2018
    ChuanXin, Sebille, LeonhardP and 2 others like this.
  18. SirStompsalot

    SirStompsalot

    Joined:
    Sep 28, 2013
    Posts:
    112
    Great job @zulfajuniadi ! Could you tell us about your implementation? Are you using ECS for anything?
     
  19. zulfajuniadi

    zulfajuniadi

    Joined:
    Nov 18, 2017
    Posts:
    117
    Nope, just plain old single threaded monobehaviours. The terrain chunks are rather small (64x64) and the heights are direct sampled from a simple perlin noise function. I don't think it would matter much if I were to switch to ECS as the bulk of the time (2ms out of the 3ms) is spent on rendering.
     
    SirStompsalot likes this.
  20. beanie4now

    beanie4now

    Joined:
    Apr 22, 2018
    Posts:
    311
    what @sibelle had in the twitter gif is this

    gridbrush.PNG I think this is what is being missed. What we have in 2018.3 is this
    minecap.PNG



    some sort of special script "grid brush" that isn't built in and I have no idea how to make...
     
  21. zulfajuniadi

    zulfajuniadi

    Joined:
    Nov 18, 2017
    Posts:
    117
  22. GoldenSkullArt

    GoldenSkullArt

    Joined:
    Aug 14, 2013
    Posts:
    49
    I have tried out those brushes and not get the desired results...


    Can you tell more about how you set up the tiles? Do you use a Z to Y map? Are there tiles underneath the elevated tiles? A step-by-step walkthrough for the setup would be nice, so I could try to replicate that with my blocky tiles.
    Are you using any Z-positioning or height? Or are you simply drawing the slopes between the heights based on the y to give the impression of height?

    Yea, I would still like to know whether putting walls on the same layer is possible at all. Might not be...I have the strong sense that it comes down to how the collision with the tiles work but I need to do some more testing.

    Cheers for the replies so far :)
     
  23. Sebille

    Sebille

    Unity Technologies

    Joined:
    Jul 23, 2018
    Posts:
    5
    So, I've talked to one of our 2D devs, and he gave me a few super helpful answers that I thought I should share with all of you!

    @Corvwyn - Regarding the use of Custom Axis Sort with LWRP: it is indeed possible to change these settings, however rather than there being a global project setting for it, the Transparency Sort Order in LWRP is now set up per-camera. Currently you have to write a bit of code and use it as a script for your cameras - but LWRP is still in preview, so there will likely be quite a few changes still and I don't see why a UI option for this wouldn't be added in the future. For now, however - here is an example script that you can use:

    Code (CSharp):
    1. using UnityEngine;
    2. #if UNITY_EDITOR
    3. using UnityEditor;
    4. #endif    
    5.  
    6. [ExecuteInEditMode]
    7. public class AxisDistanceSortCameraHelper : MonoBehaviour {
    8.     void Start () {
    9.         var camera = GetComponent<Camera>();
    10.         camera.transparencySortMode = TransparencySortMode.CustomAxis;
    11.         camera.transparencySortAxis = new Vector3(0.0f, 1.0f, -0.49f);
    12.    
    13. #if UNITY_EDITOR
    14.         foreach (SceneView sv in SceneView.sceneViews)
    15.         {
    16.             sv.camera.transparencySortMode = TransparencySortMode.CustomAxis;
    17.             sv.camera.transparencySortAxis = new Vector3(0.0f, 1.0f, -0.49f);
    18.         }
    19. #endif      
    20.     }
    21. }
    @MaxHeyderArt-GoldenSkull - First of all I wanna say, I only just realised that it was you who made these awesome isometric assets and allowed us to use them for our demos - I just wanted to say that they look awesome and I love your art style :p Also, there's some good news about Z-axis sorting you were asking about earlier!

    So, there's a few things involved that don't exactly make it obvious in regards to why it doesn't work. One of these things is the fact that by default, the Cell Size of the Isometric Grid is set to 1, 0.5, and 0 for XYZ respectively. In order for tiles to get layered correctly on the same layer using the brush settings, the Z size of the grid needs to be at least 1 - I think we might change that to be the default in the future.

    upload_2018-9-19_14-54-10.png

    Additionally, one extra thing that needs to be done is setting your Custom Axis Sort order to be a negative Z value and giving it slightly smaller priority than the Y value. So, for this example (and as is show in the code above), the values will be 0, 1, -0.49. The reason we use an odd value for Z is the fact that we want the sorting to be negative, however we still do not want it to overtake the Y-axis sort for height or to compete with it (you can do some experiments with the Z value here to see how it affects rendering).

    After changing that, you will be able to paint tiles on different heights by changing the Z Position value on your brush, as expected! Hope that helps :)

    Regarding the tweet - I did have some layers set up before, and a bit of editing to speed things up to make the gif compact:p Basically all I did in between there was change the layer and Z-value on the brush (now we know that only the last step is required). It's a good point however, it might be nice to add some more shortcuts to Tilemaps - right now the only ones I know of are for the painting tools (if you hover over them, you'll be able to see one for each tool) and that holding Shift while using the brush or the box paint tool allows you to erase sections without having to switch tools.

    Also, the 3D setup solution you've proposed definitely looks interesting! I passed it to our 2D guys, maybe in the future we can make the Grid component more customizable and allow users to have more control over the cell-to-world conversion. Thanks for the feedback!

    By the way that is awesome work @zulfajuniadi!
     
  24. GoldenSkullArt

    GoldenSkullArt

    Joined:
    Aug 14, 2013
    Posts:
    49
    @Sebille



    You are amazing!!! <3
    Thanks for finding that out for me, this is perfect.
    So. Happy. Right. Now.

    Thx for the brilliant communication and swift feedback, you lot are amazing.

    And thank you so much for your lovely and kind feedback, I am really happy you like the art and the style. <3
    It is a great honor for me to see them used and portrayed that way, so I feel deep gratitude.

    I will keep you updated if I find anything again (I hope not tho :p)
     
    Sebille and LeonhardP like this.
  25. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,514
    For this to work, must the walls be rendered with Mode set to Individual? Chunk does not work for me whether or not character/wall are in the same Atlas, but Individual works.
     
  26. zulfajuniadi

    zulfajuniadi

    Joined:
    Nov 18, 2017
    Posts:
    117
    Yes chunk would not work because it'll be rendered as one big quad mesh
     
  27. onnep

    onnep

    Joined:
    Jan 3, 2018
    Posts:
    10
    Hi,
    I wanted to ask if there is some nice way to do isometric tiles that characters can go inside. I mean that a single tile would have a front and back part.

    It almost seems to work: I can in the Tile Palette have two tiles on the same location if I those have a different z-position, but when I try to paint with those it seems that only the one on z-position gets placed.
     
  28. jeanpoolay

    jeanpoolay

    Joined:
    Mar 28, 2017
    Posts:
    8
    Hi Unity family :V
    I finally completed a "ground rule tile" who works very well \o/
    Of course I had to apply all the changes above.
    47 cubes are needed for all scenarios :F

     
    Last edited: Sep 26, 2018
  29. max4260

    max4260

    Joined:
    Mar 6, 2017
    Posts:
    10
    @Sebille Using the single tilemap for multiple Z levels works like a charm until I try to get units to render over the floor (z = 0) and under the walls (z = 1) with batch culling mode. It works on Individual, but even with an atlas I cant figure this one out.

    I didn't try actually building the game, but if i'm following correctly i assume that doesnt matter?
     
  30. zulfajuniadi

    zulfajuniadi

    Joined:
    Nov 18, 2017
    Posts:
    117
    Batching works fine in with sprite atlas, z positions and individual rendering @max4260

    upload_2018-9-29_1-44-28.png
     
  31. max4260

    max4260

    Joined:
    Mar 6, 2017
    Posts:
    10
    @zulfajuniadi I think i misspoke. Should have said I can't get chunk mode to work with a unit, not other tilemap assets.
     
  32. zulfajuniadi

    zulfajuniadi

    Joined:
    Nov 18, 2017
    Posts:
    117
    Yeah the sorting doesn't work properly if you set the draw mode to chunks. Though it should work fine with individual tiles. Even with other sprite renderers:

    https://i.gyazo.com/456da4f8a21f9b93acba9409b1014dd4.mp4
     
    Last edited: Sep 28, 2018
  33. max4260

    max4260

    Joined:
    Mar 6, 2017
    Posts:
    10
    @zulfajuniadi ok, I assumed according to this post chunk would work with an atlas. maybe its a bug?
     
  34. SirStompsalot

    SirStompsalot

    Joined:
    Sep 28, 2013
    Posts:
    112

    Nice screenshot. Curious, did you have any advice for multi-tile objects such as structures.
     
    Sylmerria likes this.
  35. gotenxds

    gotenxds

    Joined:
    Sep 22, 2018
    Posts:
    12
    Hello, I'm trying to use the new isometric tilemap system.

    In my example I'm trying to make my character move under a bridge, or show up in front of it according to where it stands on the grid.

    It works, mostly, but on some locations the player moves behind or in
    front of the bridge where he should not
     
  36. Corvwyn

    Corvwyn

    Joined:
    Nov 15, 2013
    Posts:
    114
  37. gotenxds

    gotenxds

    Joined:
    Sep 22, 2018
    Posts:
    12
    I did, and I've made the changes noted over there, this still persists.
     
  38. jeanpoolay

    jeanpoolay

    Joined:
    Mar 28, 2017
    Posts:
    8
    Hey Unity Bro', I have a question about Tint Brush: I can't tint a cube because it said "
    Tint brush cancelled, because Tile (GrassStone01) has TileFlags.LockColor set. Unlock it from the Tile asset debug inspector.
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)"
    Anybody knows what it could be happen ?
     

    Attached Files:

  39. gotenxds

    gotenxds

    Joined:
    Sep 22, 2018
    Posts:
    12
    @Sebille any updates on this? it's been a few months and tbh I feel kinda stuck on the sorting front as stated above.
     
  40. zulfajuniadi

    zulfajuniadi

    Joined:
    Nov 18, 2017
    Posts:
    117
    The sorting works fine. Hard to say why it's not working for you.


    [Video]

    These are my settings:

    upload_2018-10-5_15-13-59.png
     
  41. gotenxds

    gotenxds

    Joined:
    Sep 22, 2018
    Posts:
    12
    Hi zulfajuniadi, thx for the answer, I have the exact same settings as you, but as you can see from my video it does not work in all occasions, also, in you video you can see it does not work 100% of the time, for example the people who walk of the stone bridge are not behind the bridge pillars but walk over it.
     
  42. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
    I have also a sorting bug @Sebille :(

    Settings :

    Axes settings :


    Grid settings :


    Tilemap settings :


    "Character" settings:


    Result :

     
    GoldenSkullArt likes this.
  43. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    It would be great if you could submit a bug report for this with a minimal reproduction project and reply in here with the issue ID. This goes for your problem as well @gotenxds.
     
  44. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
    Done :)

    Case 1088821
     
    Last edited: Oct 9, 2018
    LeonhardP likes this.
  45. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    I recommend you edit your post and remove the link and post the id only, otherwise you give everyone access to all your reported and future reported bugs, which might at one time perhaps contain sensitive information which you don't really want to share with the world.
     
    LeonhardP and Sylmerria like this.
  46. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Hi, we added a guide to this here:
    Hope this helps and do post any suggestions for improving the guide!
     
  47. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    The Tiles in the Tilemap are sorted by their Sprite's pivot as well. From your video, it seems that the block has its sorting changed when moving past the center of the Grass Tile?

     
  48. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    I'm not quite certain how your bridge is set up in your scene. If you can provide more details about or file a bug report, that would help a lot!

     
  49. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    If you check your GrassStone01 Tile asset in the Debug Inspector (right-click on the inspector tab and select debug in the menu), there is a flags setting that locks the Color of the Tile. You will need to change this to allow the Tint Brush to tint a Tile.

     
    jeanpoolay likes this.
  50. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
    Thanks for the answer
    Yes
    Indeed, I just tested it for be sure