Skip to main content
Unity3D

Unity3D Scripting API # 5: FixedUpdate() ☑️

By January 25, 2021February 11th, 2021No Comments
Unity3D Scripting API

FixedUpdate():

☑️ Recap: Update used to determine the state of a game object in the next frame and thereon continuously
☑️ Called continuously after 0.02 seconds or whatever time interval that you choose. Unity’s fixed timestep defaults to 0.02. This means FixedUpdate() is being called after every 0.02 seconds
☑️ Tied in to the physics engine. Contains physics based updates
☑️ This method is a place where you should put all physics based updates like applying a force to move an object at some pre-determined fixed interval. Anything that needs to be applied to a rigidbody should happen in FixedUpdate()
💡FYI: Rigidbody component will put a game object's motion under the control of Unity's physics engine.
☑️ Script has to be enabled in order for the FixedUpdate() method to execute (even for Update() method it has to be enabled)
☑️ The refresh rate of a game does not matter for the FixedUpdate() method , it will execute after every 0.02 seconds regardless of whether the game runs at 30FPS or 60FPS
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CubeController : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Hello");
    }

    // Update is called once per frame
    void Update()
    {
        Debug.Log("Update");
    }
    void FixedUpdate()
    {
        Debug.Log("Fixed Update");

    }
}

Full list here: https://docs.unity3d.com/ScriptReference/MonoBehaviour.html

Leave a Reply