I’m having trouble finding any useful information/tutorials about the tilemaprenderer order settings (chunk and individual).
I can’t seem to get this sort of behaviour working for my project:
I found that from this reddit post: Reddit - Dive into anything
What they got going is the wall tile sorting, where the player can navigate on both sides of the wall and it being sorted properly.
But what they are doing there is apparently instantiating new game objects when the game starts. This seems like a hack, and you lose a lot of the performance benefits from the tilemap.
Is there currently no way to achieve this, other than place individual game objects? Are there no examples or anything on how to use the render mode?
To accomplish this with the TilemapRenderer2D and be able to sort individual Tiles on the Tilemap with other SpriteRenderers, you will need to make use of the Individual Mode of the TilemapRenderer2D and the camera’s Custom Sorting Axis. This will allow you to sort the Renderers based on the screen position of your Renderers where the higher you are on screen, the further back you are and therefore will be drawn before other Renderers.
It seems that the custom sorting axis option is not there when using the 2DRenderer inside the URP (LWRP). Is the feature missing or moved to somewhere else?
It is currently hidden when URP is set, which should be updated in a future URP release.
To set it, you will temporarily need to remove the URP asset to switch to Built-in RP, set the custom axis option and set back your URP asset. Alternatively, you can set the custom axis option on your Camera component itself using scripts.
Alright, that seems very unintuitive like many other things I’ve encountered with the URP.
We’ve decided to switch back to the legacy render pipeline for now, until things are more fleshed out.
For those using URP in 2021. Setting the individual sorting order is not available in the normal inspector settings, but if you switch to Debug settings, you can switch from Chunk to Individual.
My only question now, is can I set the sorting order of those individual tiles in code and how? Like can I set a tiles sorting order higher for a ceiling or low for a floor?
The TilemapRenderer lets you set Chunk or Individual Mode. It also lets you see Sorting Layer and Order in Layer for all tiles within that tilemap. https://docs.unity3d.com/Manual/class-TilemapRenderer.html In 2021, the TilemapRender shouldn’t require going into Debug mode.
There’s no way to set sorting orders for individual tiles. Typically people have several tilemaps, for example one for floor and another for walls, each with a different sorting order, and with the floor being Chunk Mode and walls being Indiivdual Mode. This ensures floor is rendered below the walls. And the wall’s Individual Mode allows it to sort vs. character in front/behind.The floor’s Chunk Mode renders it efficiently but it then loses its ability to sort properly against a character.
Special cases - like an individual object that for some reason needs to change its sorting order - might best be handled by gameobjects with SpiteRenderers.
I got that working, but there is a problem with objects that are bigger than 1 tile. Is there any way to fix this? Maybe I doing something wrong or this is just not possible with current system?