TonyTakeshi
TonyTakeshi

Reputation: 5929

How to get current moving speed of the box2d object

I apply force to the b2body, but would like to know is there a way to know what speed the b2body is after applyforce/applylinearimpulse?

b2Body* car;
b2Vec2 force = b2Vec2(0,100);
car->ApplyForce(force, car->GetPosition());

Upvotes: 3

Views: 4367

Answers (2)

renevdkooi
renevdkooi

Reputation: 1643

b2Vec2 vel = body->GetLinearVelocity();

Upvotes: 8

Andrew
Andrew

Reputation: 24846

After apply force to the center of mass:

v = F * t / m. F - force, m - body mass, t - apply time. I think it will give good approximation if no damping is used.

I'm not so sure about impulse. But, imp = m * v So by applying linear impulse to the center of mass you get imp/bodyMass velocity increment

Upvotes: -1

Related Questions