How do I stop the camera from clipping through geometry?

I have a basic first person set up. But I’m having problems when the player is close to and facing a wall. The camera will begin clipping through the wall:

I’m fairly new to game development so I’m not sure what I should do. I can make it so the player can only approach a certain distance to the wall, but it’s hard to get that to feel right.

Lower the near distance of the camera. This is the minimum distance at which the camera will render things. I think the default distance is 1 unit. You can change it by setting “default-near 0.1” in Config.prc, or in your program by setting base.camLens.setNear(0.1).

You cannot set it to 0, however, because of how the depth buffer is implemented in graphics hardware. (The lower the value, the less precision the depth buffer will have, which increases the chance of z-fighting artifacts.)

For background information: … ld_of_View

It works! Thank you.