I want to make a fps game. I have a human model with a gun, and I added a camera to its head to make it show what the model actually sees. When shooting, I want the camera to see the gun, but I'm experiencing some weird behavior in Unity. When the model is rotated forward (ingame: north) while shooting, you cant see the gun. But when rotating to all other sides, the camera sees the gun, and you can see it. I think its because the camera is colliding with the model, but why only at some angles?
asked Oct 20 '10 at 05:51 PM
It is likely not "collision" per say, especially if you didn't add any Collider to the camera and/or neither has a rigidbody. What you are likely experiencing is camera clipping. If your camera near plane is passing through the model the model (or parts of the model) will be culled. As you move the camera, there are obviously some angles at which you near clip plane is not intersecting your model.
The solution is to not have your camera's near clip plane intersect your model. Fixes include changing your near clip plane, moving your model away from the camera more, rendering your model on-top (possibly as a separate pass).
answered Oct 21 '10 at 03:49 PM
If you have an animation on the weapon mesh, try either removing the animation or change the animation settings to always update/render. Sometimes animations (skinned renderers) clip where you didn't really expect it to.
Also make sure that you are not having backface viewing where the back sides of polygons face the camera and is culled away.
answered Oct 21 '10 at 04:20 PM