6
\$\begingroup\$

I'm playing around with jbox2d and can't really make a body "fly away" as if from an explosion.

From what I have found on the net, making the body fly away from the world center (0,0), should have been something like that:

b.applyLinearImpulse( new Vec2(0,0) , b.getPosition() ); 

But really it just doesn't do anything, any idea why? Also how do I change the strength of the impulse, like if it want to make it fly skyhigh or just move a bit?

\$\endgroup\$

1 Answer 1

7
\$\begingroup\$

The first argument of applyLinearImpulse is the vector which is the strength of the force/impulse. So just change it to something else rather than 0,0 and your object should fly.

\$\endgroup\$
1
  • \$\begingroup\$ yes! :) changed it to (0,5000) and now they fly upwards. :) thanks! \$\endgroup\$ Commented May 15, 2012 at 13:33

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.