From 347eac775414619c8dd769862e0f3ec653f45dfc Mon Sep 17 00:00:00 2001 From: jasonrivalino <13521008@std.stei.itb.ac.id> Date: Sat, 11 May 2024 12:07:41 +0700 Subject: [PATCH] fix: shotgun debug for enemy --- Assets/_CompletedAssets/Scripts/Weapons/Shotgun.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Assets/_CompletedAssets/Scripts/Weapons/Shotgun.cs b/Assets/_CompletedAssets/Scripts/Weapons/Shotgun.cs index c16d970a..daf60ded 100644 --- a/Assets/_CompletedAssets/Scripts/Weapons/Shotgun.cs +++ b/Assets/_CompletedAssets/Scripts/Weapons/Shotgun.cs @@ -20,6 +20,7 @@ namespace CompleteProject Light gunLight; // Reference to the light component. public Light faceLight; // Duh float effectsDisplayTime = 0.2f; // The proportion of the timeBetweenBullets that the effects will display for. + EnemyHealth enemyHealth; // Reference to the EnemyHealth script. void Awake() { @@ -36,6 +37,8 @@ namespace CompleteProject weapon= UnityEngine.GameObject.FindGameObjectsWithTag("Shotgun")[0]; weapon2 = UnityEngine.GameObject.FindGameObjectsWithTag("Shotgun")[1]; + enemyHealth = GetComponent<EnemyHealth>(); + // UnUse weapon at init state of game UnUseWeapon(); @@ -95,10 +98,15 @@ namespace CompleteProject IEnumerator DestroyLine(GameObject shootLineObject) { float timeDisplay = timeBetweenAttack* effectsDisplayTime; + if (enemyHealth.currentHealth <= 0) { + timeDisplay = 0; + } + while (timeDisplay > 0) { timeDisplay-= Time.deltaTime; yield return null; } + shootLineObject.GetComponent<LineRenderer>().enabled = false; Destroy(shootLineObject); } -- GitLab