feat: physics sensor
This commit is contained in:
parent
0dd423944f
commit
d5a9fb1fd8
|
@ -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);
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user