diff --git a/packages/entity/traits/directional.js b/packages/entity/traits/directional.js index 55cd103..a45aad2 100644 --- a/packages/entity/traits/directional.js +++ b/packages/entity/traits/directional.js @@ -14,6 +14,7 @@ class DirectionalBase extends Trait { static defaultParams() { return { directionCount: 1, + trackMovement: true, }; } @@ -23,15 +24,19 @@ class DirectionalBase extends Trait { }; } + constructor(entity, params, state) { + super(...arguments); + this.directionCount = this.params.get('directionCount'); + } + listeners() { - return { - movementRequest: (vector) => { - this.entity.direction = Vector.toDirection( - vector, - this.params.get('directionCount') - ); - }, + const listeners = {}; + if (this.params.get('trackMovement')) { + listeners.movementRequest = (vector) => { + this.entity.direction = Vector.toDirection(vector, this.directionCount); + }; } + return listeners; } }