using UnityEngine; public class PlayerHealthController : MonoBehaviour { public static PlayerHealthController instance; // Singleton instance for easy access private void Awake() { instance = this; // Set the singleton instance } public float maxHealth; private float currentHealth; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { currentHealth = maxHealth; // Initialize current health to maximum health } public void TakeDamage(float damageAmount) { currentHealth -= damageAmount; // Reduce current health by the damage amount if (currentHealth <= 0) { Debug.Log("Player is dead!"); // Log player death } } }