In my scene, the camera is positioned at the top of a capsule. When I get too close to another mesh, the camera can see inside it, and it looks very glitchy. How do I stop this from happening? I tried increasing the size of the player’s impostor, but that doesn’t allow the player to get into gaps that the player should be able to get into easily.
playground - https://playground.babylonjs.com/#50EU7Y#1
It is not easy to see anything in your example
But seems that you just forgot to include this line in your code:
scene.collisionsEnabled = true;
Also more slowly, but perhaps better solution - check bounding box or mesh intersection for capsule and scene actors (items). If intersect is true, we can change mask for mesh or disable mesh or assign not renderable material or try to change render method for Mesh (i’m no sure about this).
It depends of you needs.
It is possible but there is already built-in function, one just need to use it properly - Camera Collisions | Babylon.js Documentation
The capsule I’m using is a physics impostor, so adding this line doesn’t really change anything
I don’t understand what you mean.
Sorry I wasn’t clear enough, but what I mean is that when the camera gets too close to a mesh (not inside a mesh, then it seems to cut off a part of the mesh. This is what I mean:
mesh when the camera is too close -
mesh when the camera is a bit farther away -
If you still don’t get it, try moving close to the green box in the scene, and moving away from it in this playground - https://playground.babylonjs.com/#50EU7Y#3
That’s what I see in your scene; what do you mean with the word “moving” and what should one move?
(I couldn’t move anything in your 1st example, but can move when collisionsEnabled)
Does the example from Documentation works as you need? - Babylon.js Playground
Maybe you need to define collision radius? As example:
camera.collisionRadius = new BABYLON.Vector3(1.5, 1.5, 1.5);
the player - wasd controls
In this playground - https://playground.babylonjs.com/#4HUQQ#1034, look around using the mouse. You can see that part of the box seems to disappear, which makes the whole thing look glitchy.
The same thing is happening in my playground too.
Hey, perhaps for camera setted up big nearClipping?
You tune minZ property for camera?
It works, thanks a lot.
camera.minZ = 0;
Works like a charm, .
Yeah