public void TakeDamage(float damage) { if (damage < CurrentHealth) { CurrentHealth -= damage; lifeDisplay.UpdateDisplay(); } else { CurrentHealth = 0; lifeDisplay.UpdateDisplay(); FindObjectOfType <SceneLoader>().LoadLoseScene(); } }
// Start is called before the first frame update void Start() { // cache lifeDisplay = FindObjectOfType <PlayerLifeDisplay>(); CurrentHealth = startingHealth; lifeDisplay.UpdateDisplay(); }