Hi all. I’ve been working on an isometric sprite based game. I’m new to Unity, but not to programming or game development in general. Right now I’m having 2 issues regarding my layering that I can’t seem to solve. I’ve scoured all over the internet to no avail, so I’m hoping for some bright ideas from this forum.
Layer setup
Since it’s an isometric game with multiple height levels, I’m using a Z-as-Y tilemap. Together with a custom sort axis of (0, 1, -0.13), it will correctly sort characters and the map tiles based on position. Characters can be in front of the walls, behind the walls, or on top of the walls, depending on their Y and Z position.
image 1: my isometric z-as-y ordering setup
This works great, and only works because the characters and tilemap are on the same layer and order.
The problems arrived when I started adding stuff.
Problem 1
The biggest issue I haven’t been able to solve, is how to display a silhouette of my characters when they are behind the walls. This is the kind of tech I’m looking to create:
image 2: my current silhouette solution behind a wall. Looks ok!
Putting a mask on the tilemap is not a solution, because it would also cause the silhouette to show up when the character is in front of that wall (like the head could clip into the mask area). Following some suggestion from another post, I added a child sprite to the character that follows the same animation, but has transparency and a higher layer. The problem I’m having with this solution, is that the silhouette now shows up whenever the character is behind anything, even another character. This looks weird, and is not what I want. I only want it to show up behind my tilemap, and possibly other objects which I can specify.
image 3: my current silhouette solution behind another character. Looks weird…
Problem 2
Tiles can be selected. Both for selecting the actual tile, and for displaying possible movement. Sometimes these selections can be on tiles that are not visible to the player, such as behind a wall. Since I still want these “selected tiles behind walls” to be visible, the tile selector is on a higher layer. Problem with this is, it now also overlaps everything else, such as characters. I half solved this by adding a Sprite Mask to the characters, and have the selector set to “Visible Outside Mask”. Problem is, you can’t set a material for Sprite Masks. My characters can have an outline when they are selected, which is rendered through a shader material. This outline is not masked. I want the outline in front of the selector too.
Ideally, I’d get rid of the Masking solution altogether. It feels like a hack. Is there a better way to do this, or at least a way I can get my outline to show up above the selector?
image 4: my current tile selection solution.
This is what it looks like now. I want the blue outline over the selector as well, just like the character.
I’m not afraid of getting my hands dirty with shaders, render textures, or anything you might throw at me. Just know that I’ve already looked at these directions for solutions, so please be specific if you have an idea. Thank you!