Neues Projekt
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class Health : MonoBehaviour
|
||||
{
|
||||
[Header ("Health")]
|
||||
[SerializeField] private float startingHealth;
|
||||
public float currentHealth { get; private set; }
|
||||
|
||||
private bool dead;
|
||||
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
currentHealth = startingHealth;
|
||||
}
|
||||
public void TakeDamage(float damage)
|
||||
{
|
||||
if (currentHealth > 0)
|
||||
{
|
||||
currentHealth -= damage;
|
||||
Debug.Log($"{this.gameObject.name} was hit. Health: {currentHealth}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"{this.gameObject.name} is Dead");
|
||||
dead = true;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user