Despite the hours spent in front of box2d, I still don't understand how applyforce and applyimpulse work. I tried using some visuals to better understand what was going on (by creating lines between the position of the body and the point of the application), but the more I try, the less it makes sense.
I would like to use applyimpulse so that my box2d body jumps in the direction of the application point (mouse coordinates in this attempt). He goes anywhere except the right point ...
Here are some of my attempts:
b.ApplyImpulse(
new b2Vec2(g.mouseX/SCALE,g.mouseY/SCALE),
new b2Vec2(b.GetPosition().x,b.GetPosition().y));
and vice versa
b.ApplyImpulse(
new b2Vec2(b.GetPosition().x,b.GetPosition().y),
new b2Vec2(g.mouseX/SCALE,g.mouseY/SCALE));
both produce unpredictable results that I don’t understand at all.
Can someone explain ApplyImpulse to me as if I was 5 years old? How can I determine the intensity of the pulse? And the direction? No one seems to explain this on the Internet.
, , -, , Box2d.
!