I’m trying to do a first person view and import a complex mesh (a small car). My goal is to make a simple collision between the camera and the car. For this I use checkCollision, but for all complex meshes I encounter this problem: a lot of loss of framerate (7 fps on the playground !).
I made this playground: https://playground.babylonjs.com/#V6HD12#3
Welcome to the community!
The car mesh is indeed very complex, over 120k triangles, so this is expected behavior. CheckCollisions has to check every triangle of the mesh on every frame, so the more triangles there are in the scene, the slower the check will become. To avoid this complex check, you could parent the mesh to a transparent cube that covers the mesh, and check the collisions with that cube, so the collision algorithm would have many less faces to check
Thanks a lot
You want to say like this ?
It creates a kind of tremor, I think I’m wrong somewhere
Yup, like that The tremors happen because when you’re trying to walk inside the collision area, the collision area is pushing you back at the same time. So it creates this effect. By experimenting a bit, I think making the collision ellipsoid a bit taller alleviates this effect: Test Collisions | Babylon.js Playground (babylonjs.com)