0
\$\begingroup\$

I'm making a FPS game in Unity3d with a lot of weapons, but when I'm aiming I can see through the weapon. I know I can adjust the near clipping panel, but when I do that, my terrain starts flickering. Is there some solution?

\$\endgroup\$
0
\$\begingroup\$

A common solution to this problem is to create a second camera that only renders a specific custom layer. Then, you simply put the weapon in that same layer. The environment and UI are drawn by the first camera, with its ordinary clipping planes, and the second one can be set up to correctly display the weapon without affecting any other parts of your scene.

Of course, the fact that your terrain is flickering when you adjust your camera's clipping planes might also point to another problem that might need looking into.

\$\endgroup\$
  • \$\begingroup\$ the fact that your terrain is flickering when you adjust your camera's clipping planes might also point to another problem that might need looking into. eh not really. The distance of the clipping plane determines how detailed (or rather what the depth values represent in) the z-buffer, and logically depth value needs are different for small stuff close to the camera, like the weapon in your hand, than big stuff far away, like distant terrain. \$\endgroup\$ – jhocking Feb 16 '17 at 17:05
3
\$\begingroup\$

You could render the weapon in a separate pass/camera, and just overlay the weapon onto the other view. In Unity this is pretty easy to do by adjusting stuff like the Clipping Mask and Clear Flags of the Camera.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.