I'm implementing Box2D for my 2d top down LIBGDX game and i have some struggle with two dynamic body. Currently, my two bodies are created that way :
Code: Select all
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.DynamicBody;
this.body = world.createBody(bodyDef);
PolygonShape collider = new PolygonShape();
FixtureDef fDef = new FixtureDef();
fDef.density = 0f;
fDef.friction = 0f;
fDef.restitution = 0f;
fDef.shape = collider;
Here is what happen when my 2 players collide : http://gfycat.com/InnocentHotAracari
So basicly, no rotation, no friction and no restitution. Also, my world have a gravity of 0 (since it's a 2d top down game, i don't that want them to fall). When player 1 collide with player 2, player 2 is moved backward like it was push but i don't want that. I want it to stay where he is, blocking the path to player 1 but he can also move.
Is there a way to do that ? I have looked for some tips like catching collision with the contact listener but i don't know what to do in the preSolve method.
I'd like some help, thanks !