Gun goes through wall in a FPS

Im making a FPS, and the gun will go through walls and stuff. How do I make it like call of duty, where the gun will always be visible, no matter what?

  1. Create new camera and remove standard listener component
  2. Parent new camera to your main camera
  3. Create tag for the gun on layer 11 or another free layer (you’ll see why in the next step) and then change the layer from default to the new gun layer created
  4. In the new camera’s inspector option, set clear flags to depth only, culling mask to the newly created gun layer and change depth to something like 80 (higher numbers are drawn on top)
  5. go back to main camera and remove the gun from culling mask

Put the gun on a separate layer and have it be rendered by another camera, which is on top of the main camera and only renders the gun layer. See the docs (the section called "depth only").

You can always put a collider on the tip of the gun... That works for me at least.

ya the same thing happened to me. u know when u add character controller to ur player and a green capsule appears, just make sure that the gun is inside that capsule. change the radius that worked for me

doesn’t it technically still clip through the wall though? its just an optical illusion that it doesn’t?
my prefabs from my weapon still appear on the other side of the wall!
I have colliders on my walls and my sphere(gun) and the green-wireframes are slightly larger than the objects.
I have checked the physics layers and made sure they are set to recognize each other.
The prefab is set to load from an empty child within the body of the sphere.

I fixed this issue in a simple way. By taking a step back when my weapon bumps on something. It works absolutely fine for me. Please take a look at it Weapon Clipping Issue - YouTube
if it helps someone.