- Home /
Pause Time when certain level loaded?
Basically when the player goes back to the load level, the scores, health etc and time is still displayed but the time stops counting...until an other level is loaded, then resumes
function Update(){
if (application.loadlevel)="projector" <--then no time count.
else Timer += Time.deltaTime; <--then regular time
//something like this but with correct syntax
Answer by deltamish · Dec 25, 2012 at 02:36 PM
Hi,use Time.timeScale = 0; to pause and Time.timeScale = 1 to unpause.
var load:boolean = false;
var pause:boolean = false;
function Update(){
///At some point where you want to load another level
//Application.LoadLevelAsSync("Level1")
load = true;
if(Input.GetKeyDown(KeyCode.P))
pause = true;
if(load || pause){
Time.timeScale = 0;
}else{Time.timeScale = 1;}
}
Answer by Chuckler · Jan 22, 2013 at 01:37 AM
// For some reason that was not working? :( But this works :) Thanks This is the scrip i ended up using
private var pauseEnabled = false; function Update(){
//check if pause button (escape key) is pressed
if(Input.GetKeyDown("escape")){
//check if game is already paused
if(pauseEnabled == true){
//unpause the game
Time.timeScale = 1;
pauseEnabled = false;
}
//else if game isn't paused, then pause it
else if(pauseEnabled == false){
Time.timeScale = 0;
pauseEnabled = true;
}
}
}
Please click the check mark to mark this answer as accepted so it doesn't show up as an unanswered question
Answer by Kagutsuchi · Nov 04, 2013 at 03:20 PM
If Time.timeScale = 0; creates problems, try writing 0.0001 instead :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613085919im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to Pause game 1 Answer
An easy way to add level transitions? 1 Answer
Pause Menu Text Not Rendering 0 Answers
Can't really pause my game 1 Answer