I want to create a health bar using information that I'm currently displaying in a GUItext. The behaviour I want is for the health to decrease over time (like a countdown timer), but increase by a small amount whenever the player collects an object.
Here is my current code:
using UnityEngine;
using System.Collections;
public class TimeText : MonoBehaviour {
public GUIText timeText;
//countdown
public float timer = 99.00f;
// Update is called once per frame
void Update ()
{
timer -= Time.deltaTime*5;
timeText.text = "Health: " + timer.ToString("0");
}
}
Here is what I would like my health bar to look like: