Health Bar complete

health bar now gets destroyed when players die, and get created when players spawn/respawn. This fixes issue where health bar stays on screen after player dies.
This commit is contained in:
djkellerman
2025-04-17 17:36:23 -04:00
parent 98f0713ebe
commit 12d740288a
5 changed files with 996 additions and 19 deletions

View File

@@ -17,6 +17,8 @@ public class Damageable : MonoBehaviour
public bool damageSelfDebug = false;
public bool dying = false;
public event System.Action<GameObject> OnPlayerPunched;
public event System.Action<GameObject> OnPlayerDeath;
public event System.Action<GameObject> OnPlayerRespawn;
private void Start()
{
@@ -111,7 +113,7 @@ public class Damageable : MonoBehaviour
}
animator.SetBool("die", true);
dying = true;
OnPlayerDeath?.Invoke(gameObject);
AudioManager.Instance.PlaySound("Death Simple");
}
}
@@ -135,6 +137,9 @@ public class Damageable : MonoBehaviour
{
damageable.ResetDamage();
}
// Trigger the player respawn event
OnPlayerRespawn?.Invoke(gameObject);
}
public void ResetDamage()