Gun through wall. [please read I don't want layering]

Hi all,

I have a question concerning the fact that my gun goes through the wall.
I already tried to do anything to make the gun collide the walls and boxes but it won’t do the right physics to stop it from getting through.
I would like a total description of how to do this.
No layering, Because I want to make a multiplayer fps not a singleplayer one and I don’t want it to look like crap which it would with the layering way of doing it.

Thanks, portrius

Many older games render the weapon in screen space and render it last (on top of all world geometry.) But newer games like BF3, where the player interacts with the world in first person render the weapon in world space, and use some animation overlay to push the gun back.

Just do a raycast along the player’s facing direction to get a value back between 0 and 1, and use that to drive the playback of the overlay animation, so as you get closer to walls or objects, the gun’s position will move back and not clip through walls.