Hey Guys I have got a C# Sharp Health Script that does that my Player has got 10 Lives if he collides with an Enemy one live will be deleted from his 10 Lives. But the problem is that the player can´t see his lives or anything. I dont know how I could make a Health Bar that will show the player how many lives he has at the moment. Could somebody maybe add that to the Script that would be sooo nice!
Heres the code:
using UnityEngine;
using System.Collections;
public class HealthController: MonoBehaviour {
public float currentHealth = 10;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void ApplyDamage(float damage)
{
if (currentHealth > 0)
{
currentHealth -= damage;
if(currentHealth < 0)
currentHealth= 0;
if (currentHealth == 0)
{
//GameOver?
RestartScene();
}
}
}
void RestartScene()
{
Application.LoadLevel (Application.loadedLevel);
}
}