September 2011
Beginner
408 pages
9h 52m
English
Let's set the startTime variable, and build the logic to handle the counting-down functionality of our clock.
startTime variable:function Awake() {
startTime = 5.0;
}Note: Five seconds to beat the game is a bit ridiculous. We're just keeping the time tight for testing. You can crank this variable up later.
function DoCountdown()
{
timeRemaining = startTime - Time.time;
}TimeIsUp() function:timeRemaining = startTime - Time.time; if (timeRemaining < 0) { timeRemaining = 0; clockIsPaused = true; TimeIsUp(); }
Debug statements so that you can see something happening:function DoCountdown() ...
Read now
Unlock full access