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.
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
}