From 12e17fccd65706857f2632302dfdf89d7e2a0b41 Mon Sep 17 00:00:00 2001 From: orsolya-st Date: Sun, 7 Jun 2026 09:20:28 +0200 Subject: [PATCH] start scene fix --- Game/Assets/Scripts/DamageHandler.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Game/Assets/Scripts/DamageHandler.cs b/Game/Assets/Scripts/DamageHandler.cs index 10f4f9a..7d8536d 100644 --- a/Game/Assets/Scripts/DamageHandler.cs +++ b/Game/Assets/Scripts/DamageHandler.cs @@ -24,10 +24,12 @@ public class DamageHandler : MonoBehaviour public AudioClip fallsound; public AudioClip splashSound; + private bool isDead = false; private void Awake() { + isDead = false; rb = GetComponent(); animator = GetComponent(); } @@ -39,6 +41,8 @@ public class DamageHandler : MonoBehaviour private void FixedUpdate() { + if (isDead) return; + float currentVelocity = rb.linearVelocityY; if (lastYVelocity >= 0 && currentVelocity < 0) { @@ -76,6 +80,8 @@ public class DamageHandler : MonoBehaviour private void OnCollisionEnter2D(Collision2D other) { + if (isDead) return; + if(other.collider.CompareTag("Finish")){ //WIN THE GAME TreeSpawner.treeCount = 0; SceneManager.LoadScene(5, LoadSceneMode.Single); @@ -104,6 +110,8 @@ public class DamageHandler : MonoBehaviour private void OnTriggerEnter2D(Collider2D other) { + if (isDead) return; + if (other.CompareTag("Minidrop")) { UpdateHealth(health + 0.2f); @@ -116,6 +124,8 @@ public class DamageHandler : MonoBehaviour public void UpdateHealth(float health) { + if (isDead) return; + this.health = health; if (health > maxHealth) this.health = maxHealth; @@ -132,6 +142,9 @@ public class DamageHandler : MonoBehaviour public void Die(String reason) { + if (isDead) return; + isDead = true; + TreeSpawner.treeCount = 0; if(reason == "hole") {