Hey guys,
I am currently working on a pause game system but I am having trouble while time.TimeScale is 0. Once the pause key is pressed it should set time.timeScale to 0 and then once it is pressed again set it back to 1. What am I doing wrong?
Main focus should be on making the WaitForRealSeonds work…
private var pressed : boolean;
private var paused : boolean;
function Update(){
if(!pressed){
if(Input.GetKeyDown(KeyCode.Pause)){
if(!paused){
Time.timeScale = 0;
pressed = true;
yield StartCoroutine(WaitForRealSeconds(0.5));
pressed = false;
}
else{
Time.timeScale = 1;
pressed = true;
yield StartCoroutine(WaitForRealSeconds(0.5));
pressed = false;
}
}
}
}
function WaitForRealSeconds(time : float){
var current = Time.timeSinceLevelLoad;
while(Time.timeSinceLevelLoad - current < time){
yield;
}
}