First Person Weapons clip with terrain geometry


Currently in a first person game I am developing in C# I find that if I aim towards an object or part of some terrain that the weapon clips through it.

I am not to wise with scripting so I would be very thankful of a possible fix.

At the moment for fixes I have thought about making the weapon on another layer to stop clipping, or to play an animation of the weapon drawing more towards the player when an object is within close proximity.

Sadly I do not know how to go about either solution so if I could be shown how to approach both methods that I have suggested or any other methods to avoid clipping then I would appreciate it.


PS: Just to reiterate I am developing the game in C#.

I’ve just figured this out recently! :smiley:
What you need to do, is draw the weapon separately, and overlay it onto the main game camera.

Put your weapon model in a new layer using the inspector, then create a new camera. Specify your main camera to not render the weapon layer. You can do this using the “culling mask” field of the camera in the inspector. Next, set the new camera to ONLY render the weapon model. Then, set the new camera’s “Depth” to 1, putting the weapon camera drawing viewport “in front” of the main camera. Finally, set the weapon camera’s “Clear Flag” to don’t clear, making the background transparent for this viewport. This should draw the weapon on top of the rest of the scene, and with no scripting whatsoever, you can draw your weapons on top of the scene.

This unfortunately didn’t help me with the issue. It worked after following your steps and setting the cameras projection to “orthographic” (with a size of approx .5).