- Home /
Time.timeScale and Time.fixedDeltaTime
I'm making a quick menu for my game, when it pops up the game time slows down to 10% normal speed while you do your quick menu stuff. then time speeds back up to 100% when you let off the button. but the scripting reference says i also need to drop down the fixedDeltaTime. but I'm not sure how to do it.
this is what i have currently, it works well enough that i don't notice any messed up physics, but i have no idea what its doing.
function actionMenu()
{
if (Input.GetButtonDown("ActionMenu"))
{
Time.timeScale = 0.1;
Time.fixedDeltaTime *= .1;
}
if(Input.GetButtonUp("ActionMenu"))
{
Time.timeScale = 1.0;
Time.fixedDeltaTime /= .1;
}
}
in the script reference, the example they give is:
// Adjust fixed delta time according to timescale
// The fixed delta time will now be 0.02 frames per real-time second
Time.fixedDeltaTime = 0.02 * Time.timeScale;
i understand the " * Time.timeScale" part but what is the 0.02?
Answer by Bunny83 · Nov 19, 2013 at 02:54 AM
It's your desired physics time step. By default the physics frame rate is 50 fps. 1/50 = 0.02
You can run the FixedUpdate at any rate you like (and your PC/device supports) but usually 50 is OK.
Your answer
Follow this Question
Related Questions
how to get smooth slow motion? 4 Answers
High Speed 1 Answer
Force mode and delta timing 1 Answer
When to use Time.deltaTime? 3 Answers
Different behavior between editor and standalone changing time step 0 Answers