AbstractMesh.moveWithCollsion does not work as expected

With collisions enabled for scene and ground, if you move the character mesh using moveWithCollsions(), the character stops moving after a while. I have seen this again and again and others have reported it too. Sometime, the character moves up the ground quite a bit. Here is a playground example to see this:

https://playground.babylonjs.com/#CCIUBV#1

Move the character using WSAD keys for a minute. You will see that the character stops moving or goes sideways when it is supposed to go forward. I looked at the current implementation of moveWithCollision() and DefaultCollisionCoordinator and I have doubts on some part of this piece of code and I think it needs some rework. But wondering if there is another CollisionCoordinator someone might have written.

Thanks
Indra

Adding @RaananW and @Cedric to have a look.

That’s interesting! Let me take a look.

2 Likes

Collision ellipsoid is centered between character feet. Half of ellipsoid is under the ground.
You can check its position with the inspector.
That said, ellipsoid will detect triangle edge collision. That’s why, character doesn’t go forward but slides on triangle edges. That’s expected.
You can lower the ground subdivisions to 0 and character will slide on the diagonal.
Now, detecting collision on a plane (and falling?) only makes sense with an ellipsoid above ground.
For that, you can use AbstractMesh | Babylon.js Documentation

2 Likes

Thanks for the investigation and the findings. I really appreciate it. So the solution then will be to put the collision ellipsoid a bit above the ground using an offset. I am going to try that and let you know.

Thanks
Indra

1 Like