Is it possible to make a object always render on top of another even if there is another object between it and the camera. Like making the gun in a FPS always render on top even if it goes trough a wall.
Im preferably looking for a way to do this with the standard version of unity, and not use any pro-only features.
Best solution is to place a second camera on the scene and put the gun in front of the other camera, set the gun to a layer of it's own and make the second camera only render the gun layer, set the camera to a higher depth than the main camera so that the gun renders over the main view and set it to depth cull so that it doesn't completely hide the main camera.
The result is that the gun will always appear above everything else. If you wanted to have the gun get shaded by lights near the player you can place the second camera as a child of the main camera so that the gun and camera move around with the player.
I manage to do this by creating a new shader and modifying the render queue.
Create a new shader, and open it. Inside the shader script find the “subshader” and inside it add ZTest Always, and save your shader. Create a new material and use the new shader you’ve created. At the bottom part of your material inspector find “renderQueue” and change this number higher than 2000. Drag the material to the object you want to render on top of others.
This doesn’t work for me in Unity 2019 and using VR. I’ve followed the above instructions, created a second camera as a child of the main one, set its depth to 1, created the new layer for my object etc. but it doesn’t render the object. Any additional setting or requirement that needs to be fulfilled?