0
votes

I set a contact listener on my world and for some reason it isn't getting called when fixtures collide. I can confirm that the fixtures are indeed colliding with a box2dDebugRenderer. I have a suspicion that the problem "could" be that each frame for the player, I remove the fixture and add a new one (Because there is no way (that I know of) to resize/re-position fixture). I am adding the listener to the correct world, the world is working correctly, act is being called (ofcourse). Thanks for your help!

This is called each frame in the player class :

private void createFixture(boolean remove) {

    if (remove) {
        body.destroyFixture(fixture);
    }

    BodyDef bodyDef = new BodyDef();
    bodyDef.type = BodyDef.BodyType.KinematicBody;
    bodyDef.position.set(0, 0);
    body = world.createBody(bodyDef);
    FixtureDef fixtureDef = new FixtureDef();
    CircleShape circle = new CircleShape();
    circle.setRadius(getWidth() / 2);
    circle.setPosition(new Vector2(0, getY() + getHeight() / 2));
    fixtureDef.shape = circle;
    fixture = body.createFixture(fixtureDef);

    circle.dispose();
}
1

1 Answers

0
votes

You are missing filterdata in your FixtureDef. You have to set category bits and mask bits.

Try this:

fixtureDef.filter.categoryBits = 1;
fixtureDef.filter.maskBits = 1;