You've successfully subscribed to Hacking with Unity - Learn how to create your own games
Great! Next, complete checkout for full access to Hacking with Unity - Learn how to create your own games
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.

Time.time vs. Time.detaTime and Update vs. FixedUpdate

Ben Liu
Ben Liu

Time.time

Time.time is a read-only value which is the amount of time after game has been started.

Time.deltaTime

Time.deltaTime is how much time passed since the last frame. It is a fixed value which you can use for time dependent activities, such as moving an object with a fixed speed.

Update()

Update() is called when every frame is refreshed, the refresh frequency is decided by the physical performance of the machine.

FixedUpdate()

FixedUpdate() is called every fixed time frame, not affected by the physical performance of the machine. FixedUpdate can run once, zero, or several times per frame, depending on how many physics frames per second are set in the time settings, and how fast/slow the framerate is.

Example of using Time.time and Time.deltaTime

public class PlayerControl : MonoBehaviour {

    void Update() {
        Debug.Log("Udpate(): time: "+Time.time);
        Debug.Log("Udpate(): deltatime: "+Time.deltaTime);
    }

    private void FixedUpdate() {
        Debug.Log("FixedUpdate(): time: "+Time.time);
        Debug.Log("FixedUpdate(): deltatime: "+Time.deltaTime);
    }
}

The output:

Time.time under Update():

Time.time

Time.deltaTime under Update():

Time.deltaTime

Time.time under FixedUpdate():

Time.time

Time.deltaTime under FixedUpdate():
Time.deltaTime

Ben Liu

Please feel free to contact me if you have any question. <br> https://t.me/NeedoneApp