Update and FixeUpdate?

hi, can i ask if fixedupdate iss more than 1 per frame ? because i se the roll a ball tut but i speak spanish so i didnt understand that part

it can be more than 1 per frame, sometimes it might be 1 for every couple frames.

FixedUpdate occurs a fixed number of times per second (or at least attempts to).

look here:

In this flow chart every full update cycle (the larger loop) the physics step occurs… in it it will calculate the change in time, and from that determine how many times FixedUpdate should be called for that amount of time. So if FixedUpdate is set at 50 times per second (0.02) and 0.05 seconds passed. It’ll call it twice, and save 0.1 to be summed into the change in time next frame. So if 0.3 change occurs the next frame, that’s 0.1+0.3 = 0.4. So Again twice, with no remainder. But if 0.3 happens again, that 0.3 + 0 = 0.3, so 1 FixedUpdate, and a remainder of 0.1.

Note… the deltatime between each FixedUpdate is not REAL time. It’s the delta time that should have occurred in simulation. Hence why it returns the same value no matter what (1/50, 0.02, if set to 50fps).

So, if your framerate goes below 50, you’ll end up calling FixedUpdate multiple times per frame at times. And if it goes above 50, you’ll have frames where FixedUpdate doesn’t get called at all.

ty!! i didnt understand u but i did with
FixedUpdate: FixedUpdate is often called more frequently than Update. It can be called multiple times per frame, if the frame rate is low and it may not be called between frames at all if the frame rate is high. All physics calculations and updates occur immediately after FixedUpdate. When applying movement calculations inside FixedUpdate, you do not need to multiply your values by Time.deltaTime. This is because FixedUpdate is called on a reliable timer, independent of the frame rate.

FixedUpdate is dependent on its Time.fixedDeltaTime and how much time as passed since the last frame. FixedUpdate then plays “Catch up”, looping FixedUpdate until it has caught up or reached the Time.maximumDeltaTime allowed per frame.

For example you set the values:
Time.fixedDeltaTime = 0.025f (giving an estimated 40 fixedUpdates per second, usually a little less)
Time.maximumDeltaTime = 0.2f (limiting you to <=8 fixedUpdates per frame)

The following frames took a variable time run.
Frame 1: took 0.16 seconds
Frame 2: took 0.13 seconds
Frame 3: took 0.35 seconds

Note: fixedDeltaTime and frames is usually much smaller (like 1/10th the values i posted). I just simply used larger values so there wasn’t as many 0’s (the concept is still the same).

thus FixedUpdate will run:
Frame 1: min(0.2, 0.000 + 0.16) / 0.025 = FixedUpdate runs 6 times this frame (0.010 seconds left over)
Frame 2: min(0.2, 0.010 + 0.13) / 0.025 = FixedUpdate runs 5 times this frame (0.015 seconds left over)
Frame 3: min(0.2, 0.015 + 0.35) / 0.025 = FixedUpdate runs 8 times this frame (0.000 seconds left over)

Notice for frame 3 that if it had used 0.015+0.35 = 0.365, it would have run 14 times with 0.015 seconds left over. however 0.365 exceeded the maximumDeltaTime so maximumDeltaTime was used instead.

Remember, I used larger numbers for Frames and fixedDeltaTime (while maximumDeltaTime is usually around 0.2f) so you are usually getting many more FixedUpdates per frame.

FixedUpdate updates as often as you specify it to do from:
Edit → Project Settings → Time → Fixed Timestep