So, what i want:
What i've tried:
switch (fixA.getFilterData().categoryBits | fixB.getFilterData().categoryBits) {
case Game.PLATFORM_BIT | Game.PLAYER_BIT:
if (playerBody == contactEntityA.getBody()) {
if (playerBody.getBody().getPosition().y <
contactEntityB.getBody().getPosition().y + .5 || playerController.isDownPressed()) { // .5 is half height of platform body
contact.isEnabled = false;
}
} else {
if (playerBody.getBody().getPosition().y <
contactEntityA.getBody().getPosition().y + .5 || playerController.isDownPressed()) { // .5 is half height of platform body
contact.isEnabled = false;
}
}
break;
}
My problem is:
Box2d doesn't make contacts if body doesn't move for a few seconds. So after some time, contact doesn't occur and i can't move down.
Simple hack helped me. I'm just applying little velocity to a body each frame.
playerBody.applyLinearImpulse(0f, .000001f, .5f, .5f, true);
I'm not sure that is the best solution, write me please if you know how to do better.