I want to apply a force to my object in the direction that it is currently facing, here is my code so far but it is throwing errors when I try do force * t
, what am I doing wrong?
b2Transform t;
t.Set(b2Vec2(0, 0), spaceCraft->GetAngle());
b2Vec2 force = b2Vec2(0, 2.5f);
spaceCraft->ApplyForce(force * t, spaceCraft->GetPosition());
I can't try right now but something like that should do it:
float magnitude=2.5f;
b2Vec2 force = b2Vec2(cos(spaceCraft->GetAngle()) * magnitude , sin(spaceCraft->GetAngle()) * magnitude);
spaceCraft->ApplyForce(force, spaceCraft->GetPosition());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With