- Home /
How to PAUSE A game for perticular time
I want to give delay to my game in the starting and don't want to move or work any object except the main game players Animation.
He specified "except the main game players Animation". I'm not sure that your solution can handle this case.
Oh YES, I forgot that animation will stopped when timeScale = 0, sorry. I suggest the answer by "Nguyen $$anonymous$$ichaël".
Answer by Mikilo · Jan 29, 2013 at 10:00 AM
Hi,
I never try something like that. But you could try to write a script that will disable the GameObject in Awake(). In Update(), you wait until your delay passed, and then enable and destroy your component.
Or maybe, write a script that will disable all GameObjects in the scene except the one you want and wait for the delay to enable.
Answer by Halogenic8 · Jan 29, 2013 at 01:00 PM
A solution I've used before that is quite flexible if your game has a lot of pausing and resuming in it is to broadcast a message called "OnPause" or something similarly named.
Any gameobjects that you want to receive it should implement the method OnPause (to receive the message) and do some conditional logic probably involving a 'paused' boolean. So you can do something like this in Update():
bool paused = true;
void Update()
{
// only do some stuff if paused is false
if (!paused)
{
doSomeStuff();
}
}
void OnPause()
{
paused = true;
}
You can also implement a resume message to unpause any currently paused gameobjects by setting the 'paused' boolean back to false;
void OnResume()
{
paused = false;
}
With the code above all of your gameobjects will start paused until you broadcast the "OnResume" message.
Answer by Milo_del_mal · Feb 08, 2013 at 09:40 PM
In addition to the previous comment... You want to Disable your rigid bodies when you are on pause, and re enable them on resume.
Your answer
Follow this Question
Related Questions
Moving Platform with delay not working 0 Answers
Make enemy wait before attacking player 2 Answers
Pause menu... Isn't pausing everything... 1 Answer
How to save players position then load a level (pause menu) 2 Answers
pause the audiolistener of the main camera doesn't stop it from generating sound 0 Answers