in my game you have to collect things in a certain amount of time. If you have failed you must re-do the level or if you pass the time will become less
I want to reset timer using a GUI button, should i be using delta instead of time.time as i know this counts from the start of the scene
when i click my GUI button the timer stays at 0 please help ![]()
this is my script so far
var isPaused : boolean = false;
static var startTime : float; //(in seconds)
static var round : boolean;
var timeRemaining : float; //(in seconds)
var GuiText : GUIText;
function Awake(){
startTime = 10.0;
}
function Update() {
if (!isPaused)
{
// make sure the timer is not paused
DoCountdown();
}
}
function timer(){
startTime = 10.0;
isPaused = false;
}
function DoCountdown() {
timeRemaining = startTime - Time.time;
ShowTime();
if (timeRemaining < 0)
{
Roundendscript.End = true;
GameController.Over = true;
isPaused = true;
timeRemaining = 0;
TimeIsUp();
}
}
function PauseClock()
{
isPaused = true;
}
function UnpauseClock()
{
isPaused = false;
}
function ShowTime()
{
var minutes : int;
var seconds : int;
var timeStr : String;
minutes = timeRemaining/60;
seconds = timeRemaining % 60;
timeStr = minutes.ToString() + β:β;
timeStr += seconds.ToString(βD2β);
GuiText.text = timeStr; //display the time to the GUI
}
function TimeIsUp()
{
Debug.Log("Time is up!");
}
I don't even see an OnGUI function anywhere.
β Dreamblur