Autotile Bitmask for Topdown 2D Walls with Y Sort

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By gareththegeek

I am trying to implement a 2D topdown game. I would like for the walls to have the illusion of height (e.g. Chaos Engine). The first problem I ran into is Y Sorting. The player would either appear on top of or underneath all walls. The desired behaviour is that the player be behind a wall if they are above the wall but in-front of the wall if they are below it.

The only way I successfully achieved this effect was to use two tiles for each horzontal wall section, setting the top part of the wall to a Z Index of 1 and the lower part of the wall to a Z Index of 0. This worked great until I came to implementing the walls as an autotile.

I have not figured out a way to use a bitmask which understands that horizontal walls have two parts, a top and a bottom. I can only get a bitmask to work for the wall tops, which correctly makes corners, horiztonal and vertical sections, t-junctions, ends etc.

Any suggestions how I can achieve the desired effect? I tried enabling Y Sort for the TileMap and making the Player a child of the TileMap but this seemed to have no effect whatsoever.

Thanks!