FPS player partially clipping through walls - is this the right solution?

Hi,

Currently loving Unity, but still very much learning the basics. At the moment learning about rooms and colliders etc. My ‘test’ room currently exists of a box from Max with inverted polygons and a Mesh collider applied in Unity. The problem I was getting was that if I moved my FPS character very close to one of the walls and then looked down and along the wall (at like a 45 degree angle or something), part of the wall would be clipped away and I’d be able to see outside (which obviously I don’t want). My solution for this was to adjust the Near Clipping Plane of the Main Camera (child of the FPS component) from 0.3 down to 0.2 and this appears to have fixed it. Maybe it’s a bit redundant asking this question since my problem’s gone away, but was that the right solution or can that potentially cause other problems? I don’t really want to start having multiple ‘fake’ walls made of Unity cubes with collision boxes on them or anything like that.

Thanks in advance :slight_smile:

That’s exactly what near clipping plane does, sets the minimum distance from where your camera starts to render. and if your camera’s transform.position is very very close to the wall, and you are looking straight at the wall, it’ll start to render from 0.3 to maxclippingplane, and if 0.3 is outside the box, it will not render the box walls.

Sidenote: watch out for animations and to what object u parent the camera from, because if you have a capsule collider on your plane, and you parent the camera to the model’s head, and the model can bend his upper body right/left, based on animations, then it will intersect with walls and such. (solution: parent the camera to the capsule collider or smt)

Thanks ar0nax, and thanks for the tip also :slight_smile: