Making a 1st person game with a gun. Problem - Gun disapearing in floor/walls/props when getting close

New to these forums so apologies if this is the wrong spot, just let me know if it is!

I’ve been developing a very basic FPS and have run across a problem. The ‘model’ of the gun is vanishing when it interacts with other ojects eg walls and floor. I want the gun to work like that in games like Battlefield where the gun is always completely visible.

Hopefully this image will help explain it better (ignore the green lines on 2nd picture)

alt text

I think that this is just something easy I’ve over looked.


There are two possibilities I can think of right now: use a second camera to render the gun and overlay it on top of the other or change the gun’s shader so it is rendered last and without Z-Testing.