The simple solution would be to increase the radius of the collision ellipsoid, so that the gun never touches the wall. If that's not an option, you would have to triggern an addition collision detection from the top of the gun and if that triggers, you would have to do something to the gun like move it up or down or something. Personally, i would consider this to be overkill and i would simply live with the gun penetrating the wall, but that's just me...