# Individual tile sorting order?

Ahoy team,

I’ve scoured the net to find answers to this one, but it seems elusive.

I’d like to find out if we’re able to have a tile map where we’re able to customise the sorting order of individual tiles.

In the image below, I’m getting the sorting order for the player as a function of the Y position. Using that method, old mate has a sorting order of -22 the fence he is standing behind is at -20. When he is directly in-front of the fence, with his sprite on-top of the fence, he is at -17. The upper fence segment is at -30 (so -32 and -27 behind and in-front) and the lower fence is at -10 (-12 and -7 for positions). I can specify one sorting order for the tile map as a whole, leaving me using the most common Y position as the sorting order. If its possible to have custom sorting orders for individual tiles, I can still use a tilemap for all my cover. If not, then each tree, fence, wall, barrel etc. needs to be placed as an individual game object.

I took a look at the z position but that only seemed to affect tiles relative to each other, and the player sprite didn’t seem to pass between the tiles at separate Z positions.

I’ve seen references to having my tilemap set to individual and my project settings set to custom axis, followed by 0,1,0, which I have currently set.

Any-one able to assist with this query?

B

You don’t want to use sorting order. Instead, it looks like you want y-sorting: things with a higher y-value are sorted behind things with a lower y-value. Edit in response to your edit: to be very clear, this isn’t setting setting the Sorting Order based on y; it’s letting y-value be determining factor in sorting, which requires you to have equal sorting orders for objects you want to sort against one another.

How sorting works generally: Unity - Manual: 2D Sorting

For tilemaps that you want to sort against characters, you need Individual Mode.

Importantly, you also need to set the Transparency Sort Axis to (0, 1, 0) for it to sort correctly. You can find the Transparency Sort Axis in Graphics Settings: Unity - Manual: Graphics Or, if using the 2D Renderer, on your 2D Renderer asset.

Things that sort together need to have the same order and layer, so set it all to zero. Floors, which always render below characters and sortable items like a fence, should have a lower order, like -10, and can use Chunk mode, if a tilemap.

Finally, be mindful of your character’s SpriteRenderer: it should, like your Individual mode tilemap, have the same order/layer. Additionally, you likely want its Sort mode to be Pivot: this is the pivot point you can set in the Sprite Editor. Often, it’s correct to put the pivot near the feet. For characters composed of multiple gameobjects, it’s usually good to use a Sorting Group. This component lets you specify a single point that it uses to sort with, near the feet.

That seemed to hit the spot! Thankyou!