1
\$\begingroup\$

I've learned quite a bit of Box2D and I've succeeded basic stuff concluding ball physics.

I want to implement 'opposing forces', as the character kicks the ball with a certain strength, with the leg having a certain mass, in a certain velocity. Basically, I don't want the leg to be controlled by Box2D's world, but to be counted as an object that I (the programmer) can move freely without the b2World::Step() method affecting it (as the player controls the leg).

How do I do so? I'd be happy to have a link, as I can't seem to find one.

\$\endgroup\$
1
\$\begingroup\$

Box2d has a body type that fits your need: KinematicBody. Kinematic bodies aren't affected by collisions, you programmatically set their velocity from outside of Box2d. Also you can directly set their positions, instead of manipulating their speed, though it's not recommended.

In case when you set kinematic bodies' speed, their position is still controlled by b2World::Step(), but they aren't affected by other bodies, though other bodies are affected by them - seems like what you want.

Here's a nice tutorial on that: http://www.emanueleferonato.com/2012/05/11/understanding-box2d-kinematic-bodies/

\$\endgroup\$
  • \$\begingroup\$ Sorry for the huge delay. I found the answer and yes, it is KinematicBody that helped me \$\endgroup\$ – user3147306 Dec 17 '15 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.