Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have implemented a character in JBox2D which moves with the help of a wheel rotating at the bottom of it. The movement is the best result I've had 'till now but it's a little glitchy when the character stands on the edge. So I am thinking should I use five smaller wheels instead of a big wheel. The wheel/wheels will not be visible in the finished product, now they are drawn for debugging. Here is a video. Is there a better way to do this using JBox2D?

share|improve this question
I don't see the problem. Can you explain exactly what the issue is with your current implementation? – Byte56 Apr 9 '12 at 21:49
Well i want my character to stay on the edge even if only one 1/5 of him is on the platform and the rest 4/5 are suspended in air. – Romeo Apr 9 '12 at 22:11
Well that's what you get for using a wheel. Unless the terrain demands it I suggest just using a box. Not to mention a box feels more nimble and maneuverable. – ClassicThunder Apr 9 '12 at 22:22
Yeah, I'm not really sure what the reason for the wheel is. If you're not even going render it. Unless you're trying to cheat the physics system? You can't really complain about a wheel not acting like a square :/ – Byte56 Apr 9 '12 at 22:32
No I dont. As long as the friction is not infinite and the box's inertia is infinite you can move the box with forces and not worry about it rotating. – ClassicThunder May 2 '12 at 0:02

When using a physics system, you need to use the physics system. The way to move things around is to apply forces to them.

You mention that you'll have explosions and bullets and you want them to react correctly, that's fine. You can apply a movement force and explosions and bullets will apply their own forces too.

This will actually give you better results because your physics system needs to know all the forces and velocities of the objects to properly calculate their response. If you were to leave the physics system entirely out of the movement of your characters, when one of your characters experienced the force of an explosion, it would react as if it was standing still. Even though it may be moving towards or away from the explosion. For example: if your character is running towards an explosion, they will not be thrown back as far because of their forward momentum.

Basically, if you're using a physics system, you need to keep it up-to-date with what the objects in your world are doing.

share|improve this answer
In Box2D, this is accomplished with Body.applyForce() or Body.applyLinearImpulse(). Here's a helpful tutorial (I suggest reading the whole series): – Amplify91 Sep 29 '12 at 5:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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