diff --git a/app/ecs-systems/interactions.js b/app/ecs-systems/interactions.js index 0d62cdc..6a36a68 100644 --- a/app/ecs-systems/interactions.js +++ b/app/ecs-systems/interactions.js @@ -12,7 +12,7 @@ export default class Interactions extends System { tick() { for (const entity of this.select('default')) { const {Interacts} = entity; - Interacts.willInteractWith = 0 + let willInteract = false; const entities = Array.from(this.ecs.system('Colliders').within(Interacts.aabb())) .filter((other) => other !== entity) .sort(({Position: l}, {Position: r}) => { @@ -24,8 +24,12 @@ export default class Interactions extends System { } if (other.Interactive && other.Interactive.interacting) { Interacts.willInteractWith = other.id; + willInteract = true; } } + if (!willInteract) { + Interacts.willInteractWith = 0; + } } }