Camera goes through the meshs

Hello,
I am creating a fps and I have a little problem.
I don’t really understand why my camera goes slightly through the meshes of my scene when it is supposed to be placed in the center of my player’s head.
Yet my player’s head and my player more broadly does not go through the meshs, which is the right behavior.
I have the impression that my camera is not “really” in the center of the character’s head but “protrudes” forward.
Here is a that illustrates my problem: https://playground.babylonjs.com/#TIYKC2#1
You can use the WSAD keys to move the character.
The bottom camera is there just to see the player’s behavior.

I hope I have been understandable, Thank you in advance.

Hi.

The situation you are dealing with is connected to the camera frustum, and so called near and far clipping planes. If you worked in any 3D software you would experience same problem for the small object.

Basically, your camera near plane is clipping the object. Here you can see the image representation of what I am talking about.

You just have to set your near plane, so it doesn’t clip through the object.
https://playground.babylonjs.com/#TIYKC2#2 (line 71)

3 Likes

Nice playground example by the way, commends for that :slight_smile:

Also, you can always use inspector to play with these values and see their effect.

Great, thank you for your explanations, it’s very clear !
Being totally new to 3D, I was totally unaware of this phenomenon.

1 Like