A few solutions would be
- if the gun has collided/clipped with another object, draw it back (as you would in real life) and flag that the gun can't fire in this position. I've seen a few games that take this option
- scale down the gun mesh, put position it closer to the camera so that it appears in the same position (bottom right) and at the same scale. Scale it down so that it is within the collision radius of the player
- do a 2 pass render. First render the scene, then (without Z buffer clearing), render the gun.
- if the gun has collided/clipped with another object, draw it back (as you would in real life) and flag that the gun can't fire in this position. I've seen a few games that take this option
- scale down the gun mesh, put position it closer to the camera so that it appears in the same position (bottom right) and at the same scale. Scale it down so that it is within the collision radius of the player
- do a 2 pass render. First render the scene, then (without Z buffer clearing), render the gun.