I’m super new to Tiled, Tiled2Unity, and Unity in general. I think there’s a good chance I’m doing something wrong, but I can’t figure out what! What I’m trying to do is to get a depth-buffer working for a 2D top-down RPG game. I activated the ‘Use Depth Buffer’ button in Tiled2Unity, and I’ve looked at the code, but it doesn’t seem to be working properly. The two issues I can see are:
The ‘Placed On Layer Index’ value seems to be calculated incorrectly. I think the idea is that you should make that number the same as the layer number that your sprite is on, and then it automatically does the Z-buffer for you. However, the depth_z value in SpriteDepthInMap.cs is being multiplied by the perLayerDepth, which is calculated based on the map height. The math seems wrong, as it means that in order to get the z-buffer working in my game, I need to multiply the actual layer that my sprite is on by the height of the map in tiles. Is that the expected behavior? Basically instead of setting it to layer 2 on my sprite in Unity, I have to make it layer 40 for a map that’s 20 tiles high.
If I assume that the ‘Placed On Layer Index’ is supposed to be 40 in this situation, I end up with the z-buffer working at some map heights, but not others. If the sprite starts out in the middle of the map, it appears over the tiles above and under the tiles below, so everything is working. However, once the sprite get to a z coordinate of less than -2.45 or -1.45 or whatever, it appears below all of the tiles. So that means that the z-buffer works for everything on the bottom half of the screen, but not for anything on the top half of the screen. It doesn’t matter what position the map is in, since the z-depth is being calculated based on the map height, not position. How do I fix that?
Thank you so much!