# Why do my Box2D collisions fail when I have multiple fixtures on one body?

I'm creating my first libgdx / Box2D game where a player moves around using a mouseJoint.

My player has two fixtures, "main" and "question".

For some reason when I have these two fixtures, my player is no longer responsive to collisions or touch detection (i.e. I can't drag the player around). If I remove the "question" fixture, everything works.

Why is this? How can I fix it?

This is how I create the Player:

// create body
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.DynamicBody;
bodyDef.position.set(x, y);
bodyDef.fixedRotation = true;
body = world.createBody(bodyDef);

// player main body fixture
PolygonShape polygonShape = new PolygonShape();
polygonShape.setAsBox(bodyWidth / 2, bodyHeight / 2); // setAsBox takes half width, half height as params
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = polygonShape;
fixtureDef.restitution = 0.3f; // Bounciness - Keep value between 0 and 1.
fixtureDef.density = 3; // Mass p/sqm - Keep value between 0 and 100
fixtureDef.friction = 0.8f; // Slippery - Keep value between 0 and 1
bodyFixture = body.createFixture(fixtureDef);
bodyFixture.setUserData("player");

// player question fixture
polygonShape = new PolygonShape();
polygonShape.setAsBox(questionWidth / 2, questionHeight / 2, new Vector2(0,0), 0); // setAsBox takes half width, half height as params
fixtureDef.shape = polygonShape;
fixtureDef.restitution = 0.3f; // Bounciness - Keep value between 0 and 1.
fixtureDef.density = 3; // Mass p/sqm - Keep value between 0 and 100
fixtureDef.friction = 0.8f; // Slippery - Keep value between 0 and 1
fixtureDef.friction = 0.8f; // Slippery - Keep value between 0 and 1
fixtureDef.isSensor = true;
questionFixture = body.createFixture(fixtureDef);
questionFixture.setUserData("question");


I assume I'm doing something silly here—I'm still very much a noob when it comes to libgdx / Box2D.

• You don't specify any translations for the Shapes, is it intentional that the Fixtures overlap with the bigger completely covering the smaller? – bornander Dec 17 '14 at 9:08
• i moved the shapes over each other just for testing, i had them apart earlier - of course that made no difference. – ParampalP Dec 17 '14 at 9:40
• You got the debug-renderer turned on, right? Does everything look Ok or is something visually out of place? – bornander Dec 17 '14 at 10:02
• @bornander yep debug renderer is on and everything looks fine – ParampalP Dec 17 '14 at 10:47
• No contact filters are active, or are you setting up mask bits somewhere for the body/fixture categories? – bornander Dec 17 '14 at 11:34

fixtureDef.isSensor = true;

polygonShape.dispose()