moveWithCollision collides with meshes that are not intersecting

I’m moving a mesh around with moveWithCollisions, but there’s some strange behavior that I don’t understand.

  1. The mesh sometimes collides with the ground while moving parallel to it. You can see a small gap suddenly appear between the mesh and its shadow while walking around randomly, and the console logs “collided with ground”, which I log when the mesh.collider.collidedMesh becomes set.

  2. The mesh leaves the ground to climb onto obstacles, but sometimes this happens when the obstacles are visibly quite far from the mesh. It’s also really “aggressive”, i.e. it will climb onto things that are much too tall. This seems to depend on movement speed - increasing the speed causes the mesh to climb onto the tall block, while at lower speeds it won’t.

Auto-climbing slopes is cool, but is just plain wrong against steps. Is there a way to set the max slope, or just turn this feature off?

Here’s a playground: https://www.babylonjs-playground.com/#J3W7DY#27

Hi @alekop - Thanks for the playground. Maybe @RaananW has an idea?

movement | Babylon.js Playground (babylonjs-playground.com)

The ellipsoid defines radius and not diameter, so it needs to be half of the diameter defined by your shape. This was you won’t jump above objects that are too large for your character.
Also you need to provide a slight movement to the bottom if you want to take gravity into account. When using camera collisions it takes gravity into account, but moveWithCollisions doesn’t. TBH - I don’t see why we don’t. @Deltakosh - any reason not to take gravity into account when moving? Older versions ignore gravity as well, so changing that should be considered a breaking change.

2 Likes

My thinking was that you can simply do a moveWithCollision where you add the gravity to your direction this way you have the option to do it or not

4 Likes