,Wait x seconds for game to start.
Hello, I'm a game dev beginner. I've faced a problem with my game currently. I'm trying to make my game start after any number of seconds I want (without occupying memory, like counting to one million or something). I don't know how to delay the game's start. I would love for the function to have as a parameter a float variable. If you could help me build this function I will be very grateful. Thanks.
Comment
Answer by Ambrose998800 · Sep 03, 2015 at 02:32 AM
I don't know if this is, what you are looking for, but i've done something like this with my Intro... (JavaScript).
private var IntroIsPlaying: boolean = true; // toggles the menu on when is == false
public var x: int; // seconds to wait before show menu
function Start(){
Screen.lockCursor = false;
Cursor.visible = true;
Intro(); // calls the menu delay function (at the bottom of the script)
}
function OnGUI(){
if (IntroIsPlaying){
GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), *BlackScreen*, ScaleMode.StretchToFill); // shows a black screen as long intro is playing (hides the menu)
} else if (!IntroIsPlaying){
GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), *MenueBackground*, ScaleMode.StretchToFill); // shows the menu background
}
}
function Intro(){
yield WaitForSeconds(x);
IntroIsPlaying = false;
// StartSong.Play(); // music starts when intro is over and menu is shown
}
Your answer
Follow this Question
Related Questions
Wait 2 seconds in Update 1 Answer
Spawn delay time AT inspector... 0 Answers
Seconds from now to seven o'clock. 1 Answer
Save game - Tile based game 0 Answers