- Home /
Show Character Behind Game Object
I have been using a ZTest shader to show a character when he is behind an object. This is used in an RTS scenario where units pass behind each other and if they're sitting behind an object, they need to be selectable and visible to an extent.
The selection aspects are just fine, I've got my ray layer masks and what not working great.
However there's a couple problems with my visual set up right now. I've tried the aforementioned ztest shader, but this has a couple drawbacks with complex characters where there are multiple materials. The ztest displays the 'outline' of, say, a characters built if it is rendered differently. Is there a way to improve the robustness of the shader to ignore things in a similar way to layering game objects? I understand layers are not a concept in the shaders so I'm not sure how to go about that.
I've also tried a two camera set up, where I draw these characters that need to be visible behind these objects on a depth only camera layered above the other game camera. However, with the camera angle and view things just don't look great with this solution.
I was thinking of some sort of hybrid, but I'm not sure how I would go about it. Wouldn't the ztest shader have the same problem with multiple cameras?