I made a game a little bit like flappy bird, with its own original elements.
In the start of Flappy bird you need to click the screen to make it start.
In my game, as soon as you press play you need to hold the “bird” up.
I want it so everything is paused until i press the mousebutton.
A way i see is to go to all scripts and say “all this happen when this happens”.
But it will take to much time, so i thought there might be a easier way?
Your problem appears to be similar to pausing and unpausing the game. You can extract the relevant code from the community wiki’s PauseMenu script, and I will be reprinting the relevant code here with an explanation:
private float savedTimeScale;
void PauseGame() {
savedTimeScale = Time.timeScale;
Time.timeScale = 0;
AudioListener.pause = true;
if (pauseFilter)
pauseFilter.enabled = true;
currentPage = Page.Main;
}
void UnPauseGame() {
Time.timeScale = savedTimeScale;
AudioListener.pause = false;
if (pauseFilter)
pauseFilter.enabled = false;
currentPage = Page.None;
if (IsBeginning() && start != null) {
start.active = true;
}
}
In the above code, Time.timeScale gets set to 0 whenever the game is paused, thereby freezing all action on screen without having to make any calls to any other scripts in the scene. When the game is unpaused, Time.timeScale gets set back to the value saved before pausing (and thus freezing) the game. There are also calls to set the GameObject’s AudioListener.pause value to true or false when pausing and unpausing the game, however such calls are only relevant when you want to turn audio on and off as well.
For your purposes, focus on storing Time.timeScale to a private class member, setting Time.timeScale to 0 whenever you want to freeze your action, and then setting Time.timeScale back to your previously-stored value when you want to restart your game’s action.
MachCUBED