How to add friction to the vehicle with AmmoJS?

Hey, I was following the demo

and as mentioned in Friction not being applied to vehicle · Issue #282 · kripken/ammo.js · GitHub
the driving vehicle is not slowing down.
Does anyone know how to apply friction to the vehicle with AmmoJS?
Or is it better to go with Babylon physics for simple car driving game?

cc @Cedric and @RaananW our Physix folks :slight_smile:


Hi @neu5
Did you try to set m_rollingFriction on the body?

Another way that should work easily is to get the angular velocity of the wheel and reapply it with a damping. something like:
newVelocity = previousFrameVelocity * 0.99;


Hey @Cedric,
Thanks for replying.
I tried every kind of friction with no luck :frowning:
Doing it by hand feels somehow hacky to me :smiley:
But maybe I’ll give it a try

I don’t know if I get your question right, the problem is that your car is not slowing down after releasing the gas pedal?

What I’ve done is added breaking when we don’t press the forwards, or backwards buttons:

else if(!actions.acceleration && !actions.braking){
breakingForce += 0.03*dt

Hello @Matthias22.
Thanks for sharing the idea. It feels hacky to me too but maybe I’ll try it.

I was reading the topic

and I was wondering if the friction is not working out of the box and some digging in the AmmoJS code (custom build?) is required?
@Raggar maybe you will know?