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

· 2 min read
Time.time vs. Time.detaTime and Update vs. FixedUpdate

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