- Home /
Time.scale Issue
I have a funny wee bug with a little bit of code that used to work well; Using this:
Time.timeScale = 0.2;
yield WaitForSeconds (0.6);
Time.timeScale = 1.0;
yesterday returned the time scale just fine to normal. now only works with one more decimal - 0.06. Using 0.6 will never return the time scale to 1.0; I have no idea why this occurs, you? :)
Not sure what you're trying to do but you should keep in $$anonymous$$d that WaitForSeconds obeys timeScale and so, if your current timeScale is 0.2, then "yield WaitForSeconds(0.6)" will actually wait for 3 seconds and not 0.6. In order to wait for a specific time ignoring timeScale try using Time.realtimeSinceStartup and create your own timer.
Something like:
Time.timeScale = 0.2f; float waitTime = Time.realtimeSinceStartup + 0.6f; while (Time.realtimeSinceStartup < waitTime) yield return 0; Time.timeScale = 1f;
As for your actual problem, have you tried adding "f" to the values you're setting? (like in my example)
the code is in a checktargets function called from update. what buffles me is that it worked before. adding f don't help neither.
Answer by fateh · Jun 23, 2012 at 03:39 PM
try this line:
Time.fixedDeltaTime = 0.02 * Time.timeScale;
like this:.
function Update () {
if (Input.GetButtonDown ("Fire1")) {
if (Time.timeScale == 1.0)
Time.timeScale = 0.7;
else
Time.timeScale = 1.0;
Time.fixedDeltaTime = 0.02 * Time.timeScale;
}
}
Your answer
Follow this Question
Related Questions
Yield WaitForSeconds outside of time.Scale 7 Answers
Slowmotion Affects Pause menu 0 Answers