There is always a confusion whether to use Update or Fixed update for your script and the most common answer you get is to use Fixed update when physics is involved. You can read our post on Unity update to understand the differences. In this tutorial we will see how to slow down the frequency of FixedUpdate in Unity.
Using Time.timescale
Unlike Update, FixedUpdate responds to Time.timescale. This is used generally to pause a game in Unity. So, using Time.timescale can pause other time related function in Unity. But if you are sure, you are not using any other time-based function then you can set the Time.timescale between 0 and 1 to control the FixedUpdate frequency.
Example script
if (Input.GetButtonDown("Fire1"))
{
if (Time.timeScale == 1.0f)
Time.timeScale = 0f;
else
Time.timeScale = 1.0f;
}
Using Time.fixedtimestep in Editor settings
You cannot change this value from script.
- Go to Edit>project settings.
- Then click on the Time panel.
- Enter the desired time in Fixed Timestep.
