Hi, I apply impulse in an object in box2d iPhone app and now want to increase its speed in particuler direction....i mean i need two thing
1.through the object in a direction 2.increase speed
plz help..
Hi, I apply impulse in an object in box2d iPhone app and now want to increase its speed in particuler direction....i mean i need two thing
1.through the object in a direction 2.increase speed
plz help..
b2Vec2 force = b2Vec2(xAcceleration, yAcceleration);
force *= dt; // Use this if your game engine uses an explicit time step
b2Vec2 p = myObjectBody->GetWorldPoint(b2Vec2(0.0f, 0.0f));
body->ApplyForce(force, p);
By modifying xAcceleration
and yAcceleration
, you can make the object move with various speeds in different directions. (If you calculate angles, you might want to use force.Normalize();
and then multiply by a velocity.)