[AmmoJS] How to decrease/dampen angular velocity of an object

Hi, so I’ve been busy with implementing some dice rolling logic and most of the elements are working. Got my meshes and colliders seemingly co-operating nicely.

One last thing I’m trying to improve however is the speed at which the die stop rolling. It goes very slowly at the moment and increasing friction of either dice or ground has seemingly no effect.


Another thing I noticed is that if I add a root.physicsImpostor.setMass(1) the friction of the ground all of a sudden does have effect seemingly even though the mass of the impostor is already 1 if I log it before the call. The problem is that when I do this, the angular velocity is never modified it just retains a perpetual (-3, 0, 0) as I originally configured it, which is ofcourse also not what I desire.

Does anyone have some input on what I can do here?

I tried googling around and using .angularDamping and .linearDamping but nothing seems to actually have an effect.

Thanks in advance

This is weird, angular damping should work. when, for some reason, I can’t make the physics work the way I want, I tweak the angular/linear velocity myself.
For example, each frame, set the linear velocity to be 99.99% of the current linear velocity.

1 Like

Ok cheers I’ll try doing that instead!

So just to confirm, you don’t see anything out of the ordinary either in my playground sample right ?

I would try without doing a compound: create the convex hull as the mesh impostor. Other than that, nothing weird :slight_smile:


Cool, thanks for the input.

I must be missing something with skipping the compound structure though.

If I just do this:

mesh.position = new BABYLON.Vector3(0, 5, 0);
const impostor = new BABYLON.PhysicsImpostor(mesh, BABYLON.PhysicsImpostor.ConvexHullImpostor, {
    mass: 0,
    restitution: 0.7
mesh.physicsImpostor = impostor;
mesh.physicsImpostor.setLinearVelocity(new BABYLON.Vector3(-30, -1, 0));
mesh.physicsImpostor.setAngularVelocity(new BABYLON.Vector3(3, 0, 0));

with mesh being loaded in async-fashion as in the playground.

The object appears in the scene but doesn’t move at all, any clue why that could be?

impostors with mass == 0 are static objects. set a positive value to make the body dynamic.

1 Like

Yup that was silly, thanks!