I’ve made a simple gun which clips through the wall.
So in order to fix it I created a new material, disabled depthTest and depthWrite, assigned the material to the meshInstances of the gun, created a new layer and moved the gun to that layer which partly fixed the issue. It no longer clips through the walls.
But now the problem is that the gun is made up of multiple materials and the rendering order of these materials is messed up now.
How the gun should look:
How it looks after fixing the clipping:
I couldn’t figure out a way to fix this issue. What would be the best way to solve this?