Mesh collider bigger than mesh view

Hi people, I’m working on a little game and I found that on every imported mesh that I want to add physics I need to change the position of the origin slightly to make the mesh kind of “touch” the ground. Even if I center the pivot on the mesh center or mesh mass center it have some space between the mesh and the ground what make some things don’t work. (like a jump that the player needs to be grounded)

How can I avoid that kind of issue and make the mesh collision be at the same place as the mesh edge?

Like on this PG, the cat has a jump if you hit space, but its not jumping because the collider is slightly away to the mesh and the canJump variable don’t switch to true and the cat cannot jump.

I “solve” that kind of error just with moving the pivot of the mesh a little bit to the top, but for me that isn’t a proper solution, its more like a work around and I want to know the right way to deal with it

Hi Alecell,

I may be misunderstanding your approach, but it looks like you’re using AbstractMesh.intersectsMesh to try to detect if the player is touching the ground. I don’t think this is the right check because, if the physics engine is doing its job correctly, a physics imposter at rest won’t actually intersect the thing it’s resting on because it’s on top of it, not in it. Instead, it might be better to check for collision between the mesh and the ground and just re-enable jumping when the cat hits the ground.

Infinite scrolling parallax with player | Babylon.js Playground (

There are downsides to this approach — it’ll re-enable jumping no matter how your cat impacts the ground, so you don’t have perfect control — so a raycast-based solution like the one used in this (heavily outdated) FPS controller Playground might be better long-term, but either way I’d probably recommend basing your logic on something from the physics system as opposed to mesh logic. Hope this helps, and best of luck!

1 Like