- Home /
how can I freeze the scene while watching a gui window ?
hello, I'm trying to find out how to freeze my scene. I have posters in my 3d scene, and when I click on them, a gui window appears on the screen to read the poster more easily. what I want is to freeze the 3d scene behind while the gui window is on. and re-activate the movement when we close the window.
thanks for your help !!!
Answer by crazyKnight · May 31, 2011 at 08:47 AM
To pause the scene
Time.timeScale=0;
To resume the scene
Time.timeScale=1;
From the posting times, it looks like the two of you might've been typing simultaneously, so he didn't copy you, it's just that great $$anonymous$$ds think alike. :)
Answer by Dreamer · May 31, 2011 at 08:48 AM
When you want to freeze scene:
Time.timeScale = 0;
When you want to resume:
Time.timeScale = 1.0;
Answer by save · May 31, 2011 at 09:07 AM
If you want movement in some areas you can wrap everything that has continuous movement with something like:
if(!paused) {
//code that moves objects
} else {
/*Freeze position and rotation of any rigidbodies
and loop through in a function all rigidbodies
to get their current velocity. Later apply
the same force on resume.*/
}