From 425628dc63e205b46eaa0bcb3c0b61ec497d97f0 Mon Sep 17 00:00:00 2001 From: Adrian Paschkowski <git@wasdennnoch.me> Date: Wed, 14 Apr 2021 17:45:03 +0200 Subject: [PATCH] Dead fighters shouldn't face the enemy --- Assets/Scripts/Fighters/AntiPlayer.cs | 2 +- Assets/Scripts/Fighters/Enemy.cs | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/Fighters/AntiPlayer.cs b/Assets/Scripts/Fighters/AntiPlayer.cs index 5c43430..8a7fb9f 100644 --- a/Assets/Scripts/Fighters/AntiPlayer.cs +++ b/Assets/Scripts/Fighters/AntiPlayer.cs @@ -36,7 +36,7 @@ public class AntiPlayer : Fighter, IFighterCallback protected override void Update() { base.Update(); - if (currentTargetEnemy == null) + if (!alive || currentTargetEnemy == null) { return; } diff --git a/Assets/Scripts/Fighters/Enemy.cs b/Assets/Scripts/Fighters/Enemy.cs index 79f775e..88d1512 100644 --- a/Assets/Scripts/Fighters/Enemy.cs +++ b/Assets/Scripts/Fighters/Enemy.cs @@ -20,10 +20,13 @@ public abstract class Enemy : Fighter protected override void Update() { base.Update(); - // Always face the AntiPlayer - var scale = transform.localScale; - scale.x = transform.position.x < antiPlayer.transform.position.x ? -initalScale.x : initalScale.x; - transform.localScale = scale; + if (alive) + { + // Always face the AntiPlayer + var scale = transform.localScale; + scale.x = transform.position.x < antiPlayer.transform.position.x ? -initalScale.x : initalScale.x; + transform.localScale = scale; + } } protected override bool CanAttack() -- GitLab