# FixedUpdate()

> Update called at regular, fixed intervals as part of Unity's physics update loop.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)

```csharp
public void FixedUpdate()
```

### Remarks

The interval between calls is determined by the value of [Time.fixedDeltaTime](/engine/6000.0/script-reference/unityengine/time/fixeddeltatime.md). You can modify this value from code or by updating the **Fixed Timestep** value in the Unity Editor's [Time settings](/engine/6000.0/manual/unity-editor/editor-settings-reference/comp-manager-group/class-time-manager.md). The default is 0.02 seconds (50 calls per second). Use `FixedUpdate` to perform physics system calculations. For example, use `FixedUpdate` when applying a force to a [Rigidbody](/engine/6000.0/script-reference/unityengine/rigidbody.md). Unlike [MonoBehaviour.Update()](/engine/6000.0/script-reference/unityengine/monobehaviour/update.md), which is called once per rendered frame, `FixedUpdate` may be called zero, one, or multiple times per frame depending on the frame rate and simulation needs. This ensures that physics calculations remain consistent and deterministic, regardless of how fast the game renders frames. Use [Application.targetFrameRate](/engine/6000.0/script-reference/unityengine/application/targetframerate.md) to set a target frame rate. For more information on managing frame rate variation, refer to [Handling variation in time](/engine/6000.0/manual/scripting/object-oriented-development/managing-time-and-frame-rate/time-handling-variations.md). The following example compares the number of `Update` calls against the number of `FixedUpdate` calls.

### Examples

```csharp

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

// GameObject.FixedUpdate example.
//
// Measure frame rate comparing FixedUpdate against Update.
// Show the rates every second.

public class ExampleScript : MonoBehaviour
{
    private float updateCount = 0;
    private float fixedUpdateCount = 0;
    private float updateUpdateCountPerSecond;
    private float updateFixedUpdateCountPerSecond;

    void Awake()
    {
        // Uncommenting this will cause framerate to drop to 10 frames per second.
        // This will mean that FixedUpdate is called more often than Update.
        //Application.targetFrameRate = 10;
        StartCoroutine(Loop());
    }

    // Increase the number of calls to Update.
    void Update()
    {
        updateCount += 1;
    }

    // Increase the number of calls to FixedUpdate.
    void FixedUpdate()
    {
        fixedUpdateCount += 1;
    }

    // Show the number of calls to both messages.
    void OnGUI()
    {
        GUIStyle fontSize = new GUIStyle(GUI.skin.GetStyle("label"));
        fontSize.fontSize = 24;
        GUI.Label(new Rect(100, 100, 200, 50), "Update: " + updateUpdateCountPerSecond.ToString(), fontSize);
        GUI.Label(new Rect(100, 150, 200, 50), "FixedUpdate: " + updateFixedUpdateCountPerSecond.ToString(), fontSize);
    }

    // Update both CountsPerSecond values every second.
    IEnumerator Loop()
    {
        while (true)
        {
            yield return new WaitForSeconds(1);
            updateUpdateCountPerSecond = updateCount;
            updateFixedUpdateCountPerSecond = fixedUpdateCount;

            updateCount = 0;
            fixedUpdateCount = 0;
        }
    }
}
```
