liliaschwab 8b29c36c54 Änderungen am 15.03.2025 um 03:58 Uhr zuhause getroffen.
(Mache nach 2-4h Schlaf weiter. Noch nicht ganz fertig, aufgrund aufgrund mangelnder Zeit durch Arbeit, damaligen privaten Problemen und damals zu viel vorgenommen).
2025-03-15 03:58:28 +01:00

38 lines
727 B
C#

using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// Link zum OG Script: https://www.youtube.com/watch?v=vNL4WYgvwd8
/// </summary>
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()
{
// code from Christian
healthbar.fillAmount = (float)currentHealth / (float)maxHealth;
if (currentHealth <= 0)
{
// player is dead
// death animation
// game over screen
}
}
}