Where to set the pivots on tiles and players for an Isometric ZasY tilemap.
I am trying to create an Isometric level such that the player can move around it and go behind objects that have higher Z values, using a ZasY tilemap.
I am creating the tiles as cube shapes, and setting the Pivot to the center:
The intention is that this is a floor tile, and the player would walk on the top face. As such, I had to set the tilemap anchor points to 0,0,0 in the world, and also edit the tile palette prefab asset to set the grid anchor to 0,0,0, such that my tiles aligned correctly with the grid.
I have a simple player sprite, with a pivot at the bottom, and I have that sprite set to sort by pivot:
My transparency sort axis is set to custom: 0, 1, -0.26. Tilemap mode is "individual"
With my tilemap at z=0, and my player at z=2, things look to be correct:
Things start to fall apparent when I add a second layer, however. In this example, I've got a second layer of cube tiles at z=2, in orange:
Because the orange cubes and the player are both at z=2, only the Y position of the pivot (afaik) is used to determine the sort order.
If the bottom of the player shadow is below the centre of the cube, it renders in front of the cube, even though it is technically behind it:
If I try and do it the other way around, so that the cube appears above the tile (with custom pivot y=0.25) then even the z=0 cubes occasionally render in front of my z=2 player:
So I'm at a loss. I've looked at how the example code in the 2d techdemos does it: that has the pivot at the centre, which is the front of the top face of the cube, but even that doesn't seem to work correctly:
So at this point I'm at a bit of a loss. This seems to be a pretty straightforward use case, as far as I can tell, but I'm not sure what I'm doing wrong.
Any pointers? How should I create my sprites (flat and raised) for isometric tiles? What should the pivot points be? What about the anchor points for the tilemap, so that tiles line up correctly with the grid?