I have two problems adding a sensor fixture in the following code. The repositioning vector b2Vec2(0,50)
is not working; the second fixture is still centered at the origin of the body. Both fixtures can be seen in debug mode but I can't move the sensor fixture to the foot of the main fixture.
Secondly, when isSensor
is true
I am not receiving any PostSolve
events. When it is set to false
I get the appropriate events (along with collision). How do I make this a sensor that will not collide with other bodies but still raise events. Thank you for your help.
// FIXTURE DEF
var fixDef = new box2d.b2FixtureDef();
fixDef.shape = new box2d.b2PolygonShape;
fixDef.shape.SetAsBox((25 / 2 / SCALE), (46 / 2 / SCALE));
fixDef.density = 0.99;
fixDef.friction = 0.39;
fixDef.restitution = 0.0;
fixDef.userData = "SBody";
fixDef.filter.categoryBits = CAT.SOLDIER;
fixDef.filter.maskBits = CAT.GROUND;
this.view.body.CreateFixture(fixDef);
// ADD FOOT SENSOR
fixDef.density = 0.1;
fixDef.friction = 1.;
fixDef.restitution = 0.1;
fixDef.userData = "Foot";
fixDef.shape.SetAsBox((10 / 2 / SCALE), (100 / 2 / SCALE), new box2d.b2Vec2(0,50), 0);
fixDef.isSensor = true;
fixDef.filter.categoryBits = CAT.SOLDIER_FOOT_SENSOR;
fixDef.filter.maskBits = CAT.SHIP | CAT.GROUND;
this.view.body.CreateFixture(fixDef);