FixedUpdate() vs Update() with * Time.deltaTime?

Does it make any difference to use FixedUpdate() vs Update() with * Time.deltaTime?
I wonder if any solution have advantages, because first one seams simpler, also I wonder if it’s not more efficient (You don’t need to multiply every time)

Hi Jovian,

Welcome to our community! :slight_smile:

Use FixedUpdate for moving your game object via a Rigidbody. Do not use Time.deltaTime in FixedUpdate.

In the Obstacle Course game, we manipulate the Transform directly. That’s why we use Update and Time.deltaTime.

Is this what you wanted to know?

See also:

Hello Nina,

While I knew that FixedUpdate doesn’t need to use Time.deltaTime because it’s always called X times depending on the project settings and independently from frame times, I wonder if it’s good practice to use it instead of using the Update method with deltaTime.
Are there any advantages for using Update instead of using FixedUpdate? Because I manipulated the Transform directly with FixedUpdate without any issues.

Maybe to make the question easier to answer :smiley: Are FixedUpdate() and Update() used for totally different things, or it’s more of a matter of different approaches and I shouldn’t worry about it for now? :smiley:

FixedUpdate is supposed to be a “physics” method, and the rigidbody is part of the physics simulation. It is good practice and recommended by Unity to use FixedUpdate with the Rigidbody.

Personally, I would not override the transform.position in FixedUpdate because we cannot know if this would mess with the physics simulation. The physics simulation is not open-source, so we mainly rely on what the official Unity manual recommends.

In this course, we don’t use FixedUpdate but you seem to do your own research. Feel free to apply your knowledge and test things. In many cases, there are multiple ways to do something in Unity. :slight_smile:

1 Like

You still have to multiply in FixedUpdate. Usually we define speed (for example) as, say, 2. When we multiply that with Time.deltaTime we are effectively saying ‘twice per second’ - depending on how it’s used. If we do this in FixedUpdate, we still need to multiply to ‘split’ this 2 into small enough chunks to make it ‘twice per second’. But you should not use Time.deltaTime because it is how much time passed beween Update frames. For FixedUpdate there’s Time.fixedDeltaTime. This holds the time between FixedUpdate frames and, while it’s constant at roughly 0.016667 (60fps), it may change depending on your settings.
Like @Nina mentioned, the FixedUpdate is for physics, and you probably do not want to do any non-physics things in here and hold up the physics engine with trivial stuff.

1 Like

Here is an example how to move a game object with a Rigidbody:

Thanks both of you for explanations, now I think I feel it :smiley:
@bixarrio now I see when I made the error, if I need to multiply in both approaches I don’t see advantage of using FixedUpdate() regarding “efficiency” :slight_smile:
@Nina thanks for explaining me that, I think I needed this “It’s not open-source” and we need to kinda treat this like a black box approach, and I’ll stick to update only physics in FixedUpdate(). Thanks, for documentation regarding Rigidbody :slight_smile: Right now I’ll stay with modifying transform method, to not have any hiccups later in the tutorial.

Have good day! :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms