diff --git a/packages/entity/traits/mobile.trait.js b/packages/entity/traits/mobile.trait.js index c22d063..1621997 100644 --- a/packages/entity/traits/mobile.trait.js +++ b/packages/entity/traits/mobile.trait.js @@ -29,8 +29,7 @@ export class Mobile extends decorate(Trait) { methods() { return { - moveFor: (duration) => { - const direction = this.entity.direction; + moveFor: (vector, duration) => { let resolve; const promise = new TickingPromise(_resolve => resolve = _resolve); promise.ticker = (elapsed) => { @@ -38,7 +37,7 @@ export class Mobile extends decorate(Trait) { if (duration <= 0) { return resolve(); } - this.entity.requestMovement(Vector.fromDirection(direction)); + this.entity.requestMovement(Vector.normalize(vector)); } return promise; },