Fix Bug double Winscreen

This commit is contained in:
Shavira 2025-05-26 07:15:37 +07:00
parent c7b19923a9
commit 9efdf46c15
1 changed files with 5 additions and 6 deletions

View File

@ -41,14 +41,16 @@ public class Enemy : MonoBehaviour
transform.position = Vector3.MoveTowards(transform.position, target.position, moveSpeed * Time.deltaTime);
}
private bool isDead = false;
private async void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Bullet"))
if (other.CompareTag("Bullet") && !isDead)
{
GameObject bullet = other.gameObject;
bullet.SetActive(false);
if (health >= 1)
if (health > 0)
{
health -= damage;
@ -60,13 +62,10 @@ public class Enemy : MonoBehaviour
if (health <= 0)
{
health = 0;
isDead = true;
await ExecuteBosDeath();
}
}
else
{
await ExecuteBosDeath();
}
}
}