# Removing lateral velocity

I’m making a car that is just a box impostor without wheels. If you apply impulse on it and then turn it, the movement will continue in the same direction. It’s like in space. So I need to remove the lateral velocity and make the car controllable. How to do it?

lantern animation | Babylon.js Playground (babylonjs-playground.com)

These lines will do the trick with velocity:

var linearVel = m1.physicsImpostor.getLinearVelocity();
linearVel.scaleInPlace(0.97);
m1.physicsImpostor.setLinearVelocity(linearVel);

Thank you, but it’s not the same at all. I found a good example, but it’s for Box2D, an attempt to turn the code for babylon was unsuccessful

// lateral velocity
//mesh, impostor - main variables
var angle=mesh._rotationQuaternion.toEulerAngles().y;
var ar=angle+Math.PI/2;
var vecForward=
impostor.getLinearVelocity();
var vecRight=new BABYLON.Vector3(
-Math.cos(ar), 0, Math.sin(ar)
);
var dot=vecRight.dot(vecForward);
var vecLeft=vecRight.multiplyByFloats(
dot * impostor.mass,0,dot * impostor.mass );
impostor.applyImpulse(
vecLeft.negate(),
mesh.getAbsolutePosition()
);

1 Like