diff --git a/packages/physics/traits/collider.trait.js b/packages/physics/traits/collider.trait.js index de7c05a..7a6eb75 100644 --- a/packages/physics/traits/collider.trait.js +++ b/packages/physics/traits/collider.trait.js @@ -4,6 +4,7 @@ import {StateProperty, Trait} from '@avocado/entity'; const decorate = compose( StateProperty('isCheckingCollisions'), + StateProperty('isColliding'), ); export class Collider extends decorate(Trait) { @@ -23,6 +24,7 @@ export class Collider extends decorate(Trait) { static defaultState() { return { isCheckingCollisions: true, + isColliding: true, } } @@ -110,6 +112,9 @@ export class Collider extends decorate(Trait) { return { collidesWith: (entity) => { + if (!this.entity.isColliding || !entity.isColliding) { + return false; + } if (-1 !== this._doesNotCollideWith.indexOf(entity)) { return false; }