Hello, I'm using the following script and it works fine but I'm lost as to how to change two things.
Instead of counting up, what math would I use in the Update function to start full and count down?
I have pick ups in my levels that add to the player's time. How would I target this script and add 25 seconds back on to the countdown? Currently in my collision.js when a collision occurs with an object tagged "Battery" I add 25 to a variable named PLAYER_LIFE.
Also, is this method processor intensive? Eventually I'd like to release on the iPhone.
Thanks for any help.
var barDisplay : float = 0;
var pos : Vector2 = new Vector2(20,40);
var size : Vector2 = new Vector2(200,20);
var progressBarEmpty : Texture2D;
var progressBarFull : Texture2D;
var fullVariable : float = 200;
var decreaseRate : float = 1.00;
function OnGUI()
{
// draw the background:
GUI.BeginGroup (new Rect (pos.x, pos.y, size.x, size.y));
GUI.Box (Rect (0,0, size.x, size.y),progressBarEmpty);
// draw the filled-in part:
GUI.BeginGroup (new Rect (0, 0, size.x * barDisplay, size.y));
GUI.Box (Rect (0,0, size.x, size.y),progressBarFull);
GUI.EndGroup ();
GUI.EndGroup ();
}
function Update()
{
barDisplay = fullVariable - Time.time * decreaseRate;
}