diff --git a/frontend/src/scripts/objects/game-object-container.ts b/frontend/src/scripts/objects/game-object-container.ts index f76fcc2..eb1f61f 100644 --- a/frontend/src/scripts/objects/game-object-container.ts +++ b/frontend/src/scripts/objects/game-object-container.ts @@ -25,6 +25,7 @@ export class GameObjectContainer extends CommandReceiver { } this.player = c.character as PlayerCharacterView; + this.player.isMainCharacter = true; this.camera = new Camera(this.game); diff --git a/frontend/src/scripts/objects/player-character-view.ts b/frontend/src/scripts/objects/player-character-view.ts index fb85e93..abd8ccb 100644 --- a/frontend/src/scripts/objects/player-character-view.ts +++ b/frontend/src/scripts/objects/player-character-view.ts @@ -14,6 +14,8 @@ export class PlayerCharacterView extends PlayerCharacterBase implements ViewObje private healthElement: HTMLElement = document.createElement('div'); private previousHealth; + public isMainCharacter = false; + constructor( id: Id, name: string, @@ -50,12 +52,12 @@ export class PlayerCharacterView extends PlayerCharacterBase implements ViewObje public step(deltaTimeInSeconds: number): void { if (this.previousHealth > this.health) { - this.previousHealth = this.health; - if (OptionsHandler.options.vibrationEnabled) { - navigator.vibrate(75); + if (this.isMainCharacter && OptionsHandler.options.vibrationEnabled) { + navigator.vibrate(Math.min(200, (this.previousHealth - this.health) * 4)); } + + this.previousHealth = this.health; } - this.previousHealth = this.health; } public onShoot(strength: number) {