- Home /
Time.timeScale = 0
i have a pause menu the uses Time.timeScale = 0 but i cant use any of the scripts inside the pause menu this way please help.
Answer by Kiwasi · Aug 12, 2014 at 12:05 AM
Answers are all over the show on this one. It would certainly help get a coherent answer if you posted a specific script that was not running.
Setting Time.timeScale to 0 will stop the following from running
FixedUpdate
Anything that relies on Time.deltaTime
Coroutines once they hit a WaitForSeconds
There are several simple ways to run code while in paused mode
Any code that is in update and doesn't use Time.deltaTime will continue to run
Use Time.unscaledDeltaTime for time based functions that are independent of timescale
Use custom timers to control any coroutines that need to keep running
Setting timeScale to a very small number works, I've seen it suggested in several places on Unity Answers. However I don't like the idea and suggest you avoid it. It has the potential for unintended side effects as your game is still running when you expect it to be paused.
Bored$$anonymous$$ormon your dah man or women or other i don't know but thank you for getting to the point this is my script.
#pragma strict
var slides = false;
var dest : Vector3 = Vector3.zero;
var speed = 0.5;
private var sliding = false;
function Update(){
if (ListO.bottom){
slides = true;
}
if (!sliding && slides) {
slide();
}
}
function slide () {
sliding = true;
while (transform.position != dest) {
transform.position = Vector3.$$anonymous$$oveTowards(transform.position, dest, speed * Time.deltaTime);
yield;
}
sliding = false;
slides = false;
}
ok i changed it to unscaledDeltaTime but it says that unscaledDeltaTime isn't a part of UnityEngine.Time
its right as far as i can see. might not help but i use eclipse because $$anonymous$$onoDevelop dosn't work
Answer by khaled235711 · Aug 11, 2014 at 09:32 AM
Put Your Code OnGUI void not in Update or FixedUpdate or LateUpdate as these voids freezes
Not exactly.
void is the return type. In C# you need to specify the return type explicitly but in JS it is not mandatory.
function is the keyword used to tell compiler that it is a function. You need to explicitly specify that it is a function in JS.
These two keywords are different and have different use.
Nearly Yes but as Harshad$$anonymous$$ said void is for c# while function is for javascript. tell me if it works.
so what would i put ins$$anonymous$$d of function update in a javascript script.