public void DisplayHealth() { int healthInPercentage = (int)(playerController.GetHealth() * 100 / maxHealth); if (healthInPercentage <= 0) { Destroy(gameObject); } switch (healthInPercentage) { case int n when(n >= 75): fillColor.SetColor(new Color32(89, 245, 95, 255)); break; case int n when(n >= 50): fillColor.SetColor(new Color32(248, 219, 106, 255)); break; case int n when(n >= 1): fillColor.SetColor(new Color32(251, 65, 53, 255)); break; default: fillColor.SetColor(new Color32(0, 0, 0, 255)); break; } healthText.text = healthInPercentage.ToString() + "%"; healthSlider.value = healthInPercentage; }