- Home /
Delay Gameplay While Displaying 3,2,1 go!!!
Hello, i was making a car game,When the game start's am showing 3,2,1 go!!! through Gui Text with this script
function Start ()
{
guiText.text = "3";
yield WaitForSeconds (1.0);
guiText.text = "2";
yield WaitForSeconds (1.0);
guiText.text = "1";
yield WaitForSeconds (1.0);
guiText.text = "Go";
yield WaitForSeconds (1.0);
guiText.text = "";
yield WaitForSeconds (1.0);
}
i was trying to Stop Game Play When displaying Text, Tried with Time.timeScale
but it Stopping Whole Game , i mean Even Gui Text , is there Any Way To Show Stop Gameplay While Displaying 3,2,1 go!!!???
thank you
Answer by Seth-Bergman · Jul 25, 2012 at 02:02 PM
just use a boolean to regulate everything.
static var startGame = false;
function Start ()
{
guiText.text = "3";
yield WaitForSeconds (1.0);
guiText.text = "2";
yield WaitForSeconds (1.0);
guiText.text = "1";
yield WaitForSeconds (1.0);
guiText.text = "Go";
yield WaitForSeconds (1.0);
guiText.text = "";
startGame = true;
}
then in the car script:
function Update(){
if(GUIscriptName.startGame){
//code in here won't be run until GO
}
}
OR
you could use Time.realtimeSinceStartup to check the actual time (with Time.time set to 0):
function Start ()
{
guiText.text = "3";
while(Time.realtimeSinceStartup < 1)
yield;
etc..
Answer by TheCheese · Jul 25, 2012 at 03:12 PM
There's no simple answer for this - it's a question of your game's architecture.
If your gameplay is currently triggered to start from the "Start" function, you'll have to instead create a new function called "StartRace" or something, and call that function on all the appropriate objects once the countdown is finished.
Answer by carter-carl30 · Jul 25, 2012 at 06:26 PM
you could do a seperate scene with the 3 2 1 countdown before the main game