CannonJS SphereImpostor keeps sliding even with high friction

Hi all!

Is there a way to stop a SphereImpostor from sliding on a flat plane?

Please find a link to the Playground here: https://www.babylonjs-playground.com/#3EDS3A#42

Please click inside the Playground scene to activate pointer lock.
Keys:
WASD: Move
SPACE: Jump

Replacing SphereImpostor with BoxImpostor can stop the bottom mesh from sliding, even with friction: 0 for both the bottom mesh and ground mesh.

bottom.physicsImpostor = new BABYLON.PhysicsImpostor(bottom,
    BABYLON.PhysicsImpostor.SphereImpostor, {
        mass: 1,
        restitution: 0,
        friction: 9999999999
    }, scene);

The goal is to have this bottom sphere serve as the bottom portion of a capsule for player physics

Thank you for your help :smiley:

A simpler example for your reference :slight_smile: : https://www.babylonjs-playground.com/#3PCLR#3

This is a modified version of @RaananW’s Capsule Playground in Capsule Impostor with Cannon and Babylon - Questions & Answers - HTML5 Game Devs Forum

Added bottom.physicsImpostor.physicsBody.angularDamping = 1, which reduces a lot of sliding. However, there is still a little bit of sliding while on the red slide.

https://www.babylonjs-playground.com/#3EDS3A#47

Reference: physicsBody: angularDamping/linearDamping question

To achieve the physically impossible, you will have to go to the weird realm of sleeping objects! :slight_smile:

https://www.babylonjs-playground.com/#3EDS3A#52

When the two collide, put the sphere to sleep. You can call wakeUp whenever you want to keep it going.

Not sure about your usecase, but that would be the way to go for me. Either that or constantly setting liner velocity to 0,0,0 on each frame.

2 Likes

Thank you so much for your awesome suggestions, @RaananW :smiley:

1 Like