add companion only on local player

This commit is contained in:
Johannes Berthel 2021-04-02 17:14:34 +02:00
parent 5a91e15580
commit 2ad712807b
3 changed files with 53 additions and 28 deletions

View file

@ -27,6 +27,8 @@ export class Player extends Character implements CurrentGamerInterface {
//the current player model should be push away by other players to prevent conflict
this.getBody().setImmovable(false);
this.addCompanion();
}
moveUser(delta: number): void {
@ -58,6 +60,11 @@ export class Player extends Character implements CurrentGamerInterface {
direction = PlayerAnimationDirections.Right;
moving = true;
}
if (this.companion) {
this.companion.step(delta);
}
if (x !== 0 || y !== 0) {
this.move(x, y);
this.emit(hasMovedEventName, {moving, direction, x: this.x, y: this.y});