Teaching Newbies since 2014

kauress

  • Home
  • Javascript ❤
    • JavaScript
    • Node.js
  • WebDev Tuts
  • screencasts
  • Resources
  • VR & AR
  • Contact
  • Github
  • Twitter
  • YouTube
  • RSS
  • C++
You are here: Home / Unity3D / Unity3D Scripting API # 5: FixedUpdate() ☑️

January 25, 2021 by: Kauress

Unity3D Scripting API # 5: FixedUpdate() ☑️

⭐ 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

Introduction to C# in Unity3D #1: 💻What? Why? How
Introduction to C# in Unity3D #2: Scripts! Scripts! Scripts! 📑

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2021 ·Kauress