Friday, June 23, 2017

java - Box2D platformer movement. Are joints a good idea?


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?



Answer




: 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


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...