using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; /// /// Link zum OG Script: https://www.youtube.com/watch?v=vNL4WYgvwd8 /// public class Health : MonoBehaviour { public int maxHealth = 5; public int currentHealth = 5; public Image healthbar; // health logic void Start() { currentHealth = maxHealth; } // take dmg logic private void Update() { TakeDamage(); } void TakeDamage() { healthbar.fillAmount = (float)currentHealth / (float)maxHealth; if (currentHealth <= 0) { // player is dead // death animation // game over screen } } }