using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; public class PlayerHealth : MonoBehaviour { public GameObject gameOver; public TMP_Text text; void Update() { text.text = $"{GameManager.Instance.health} / {GameManager.Instance.startHealth}"; if (GameManager.Instance.health <= 0) { StartCoroutine(GameOver()); } } private IEnumerator GameOver() { gameOver.SetActive(true); yield return new WaitForSecondsRealtime(5f); SceneManager.LoadScene(0); } }