4
\$\begingroup\$

So i smashed my brains trying to make my character move. As i wanted later in the game to add explosions and bullets it wasn't a good idea to mess with the velocity and the forces/impulses didn't work as i expected so something stuck in my mind: Is it a good idea to put at his bottom a wheel(circle) which is invisible to the player that will do the movement by rotation? I will attach this to my main body with a revolute joint but i don't really know how to make the main body and wheel body to don't collide one with each other since funny things can happen. What is your oppinion?

\$\endgroup\$
4
\$\begingroup\$

: Is it a good idea to put at his bottom a wheel(circle) which is invisible to the player that will do the movement by rotation?

That is exactly what you should. I once wrote a tutorial on it for C#/XNA and Farseer, but you should be able to adopt it easily to Java and Box2D (Farseer is based on Box2D).

Here's the tutorial:

http://www.sgtconker.com/2010/09/article-xna-farseer-platform-physics-tutorial/

The end result should be something like this: Platformer

And a video: http://www.youtube.com/watch?v=iC_Y9Tq5JeU&feature=player_embedded

\$\endgroup\$
  • \$\begingroup\$ Thank you. I know what Farseer is, i have a little experience with XNA. Thank for your advice and tutorial. :D \$\endgroup\$ – Romeo Apr 7 '12 at 19:49
  • \$\begingroup\$ I don't imagine that this would produce the best results for anyone trying to make an old-school style platformer. The rounded shape will not match the visual shape of the character, so the character will fall/slide/sink when standing near ledges. A large part of the design of a platformer's feel and mechanics is getting the sprite's feet to match the bounding shape that the character "stands" with. \$\endgroup\$ – Sean Middleditch Apr 8 '12 at 10:33
  • \$\begingroup\$ That's where the two rays come in. Also the wheel has almost infinite friction and the body can not tilt so you would only appear slightly lower (depending on the wheel size) when near an edge, which is a good visual indicator. I'm afraid this is a very common technique. I would also argue that a large part of game design is faking stuff so that it feels right, but that this doesn't mean that it is right :). \$\endgroup\$ – Roy T. Apr 9 '12 at 21:14
  • \$\begingroup\$ @RoyT. is there a name for this type of character movement? struggling to find more info on it \$\endgroup\$ – eskimo Dec 4 '13 at 13:53

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.