在以下代码中添加传感器夹具时遇到两个问题。重新定位矢量b2Vec2(0,50)
不起作用;第二个夹具仍然以身体的原点为中心。在调试模式下可以看到两个夹具,但我无法将传感器夹具移动到主夹具的底部。
其次,我什么时候没有收到任何isSensor
事件。当它设置为我得到适当的事件(以及碰撞)。我如何使它成为一个不会与其他物体碰撞但仍会引发事件的传感器。谢谢您的帮助。true
PostSolve
false
// 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);