feat: physics sensor

This commit is contained in:
cha0s 2019-04-19 02:52:39 -05:00
parent 0dd423944f
commit d5a9fb1fd8
2 changed files with 9 additions and 0 deletions

View File

@ -153,6 +153,9 @@ export class Body extends AbstractBody {
mask = mask | ctor.collisionCategory(group); mask = mask | ctor.collisionCategory(group);
} }
this.setCollision(category, mask); this.setCollision(category, mask);
if (entity.isSensor) {
MatterBody.set(this.matterBody, 'isSensor', true);
}
} }
else { else {
this.setCollision(0, 0, -1); this.setCollision(0, 0, -1);

View File

@ -13,6 +13,7 @@ export class Collider extends decorate(Trait) {
'default', 'default',
], ],
collisionGroup: 'default', collisionGroup: 'default',
isSensor: false,
} }
} }
@ -25,6 +26,7 @@ export class Collider extends decorate(Trait) {
initialize() { initialize() {
this._collisionGroup = this.params.get('collisionGroup'); this._collisionGroup = this.params.get('collisionGroup');
this._collidesWithGroups = this.params.get('collidesWithGroups').toJS(); this._collidesWithGroups = this.params.get('collidesWithGroups').toJS();
this._isSensor = this.params.get('isSensor');
} }
get collisionGroup() { get collisionGroup() {
@ -35,6 +37,10 @@ export class Collider extends decorate(Trait) {
return this._collidesWithGroups; return this._collidesWithGroups;
} }
get isSensor() {
return this._isSensor;
}
methods() { methods() {
return { return {