0
0
Unityframework~20 mins

FixedUpdate vs Update in Unity - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
FixedUpdate vs Update Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of Update and FixedUpdate call counts

Consider a Unity script that counts how many times Update and FixedUpdate are called during 1 second of game time. What is the expected output?

Unity
using UnityEngine;

public class CallCounter : MonoBehaviour
{
    private int updateCount = 0;
    private int fixedUpdateCount = 0;
    private float timer = 0f;

    void Update()
    {
        updateCount++;
        timer += Time.deltaTime;
        if (timer >= 1f)
        {
            Debug.Log($"Update calls: {updateCount}, FixedUpdate calls: {fixedUpdateCount}");
            updateCount = 0;
            fixedUpdateCount = 0;
            timer = 0f;
        }
    }

    void FixedUpdate()
    {
        fixedUpdateCount++;
    }
}
AUpdate calls: ~50, FixedUpdate calls: ~60
BUpdate calls: ~100, FixedUpdate calls: ~100
CUpdate calls: ~60, FixedUpdate calls: ~50
DUpdate calls: ~30, FixedUpdate calls: ~30
Attempts:
2 left
💡 Hint

Think about the default frame rate and fixed timestep in Unity.

🧠 Conceptual
intermediate
1:30remaining
When to use FixedUpdate instead of Update?

Which scenario is best suited for using FixedUpdate instead of Update in Unity?

AApplying physics forces to a Rigidbody
BReading player input for movement
CUpdating UI elements every frame
DPlaying animations smoothly
Attempts:
2 left
💡 Hint

Think about what kind of operations need consistent timing.

Predict Output
advanced
2:00remaining
Effect of Time.deltaTime in Update vs FixedUpdate

What will be the output of the following code snippet if the game runs at 60 FPS?

Unity
using UnityEngine;

public class TimeTest : MonoBehaviour
{
    private float updateSum = 0f;
    private float fixedUpdateSum = 0f;
    private int updateCount = 0;
    private int fixedUpdateCount = 0;

    void Update()
    {
        updateSum += Time.deltaTime;
        updateCount++;
        if (updateCount == 60)
        {
            Debug.Log($"Update sum: {updateSum}");
        }
    }

    void FixedUpdate()
    {
        fixedUpdateSum += Time.fixedDeltaTime;
        fixedUpdateCount++;
        if (fixedUpdateCount == 50)
        {
            Debug.Log($"FixedUpdate sum: {fixedUpdateSum}");
        }
    }
}
AUpdate sum: ~0, FixedUpdate sum: ~0
BUpdate sum: ~0.5, FixedUpdate sum: ~1
CUpdate sum: ~1, FixedUpdate sum: ~0.5
DUpdate sum: ~1, FixedUpdate sum: ~1
Attempts:
2 left
💡 Hint

Consider what Time.deltaTime and Time.fixedDeltaTime represent.

🔧 Debug
advanced
1:30remaining
Why does Rigidbody not move smoothly?

A developer moves a Rigidbody by changing its position inside Update(). The movement looks jittery. Why?

Unity
void Update()
{
    transform.position += Vector3.forward * speed * Time.deltaTime;
}
ABecause Rigidbody physics should be updated in FixedUpdate, not Update
BBecause Time.deltaTime is not accurate in Update
CBecause transform.position cannot be changed directly
DBecause speed variable is not initialized
Attempts:
2 left
💡 Hint

Think about how Unity physics and Rigidbody work.

🧠 Conceptual
expert
2:00remaining
Why might FixedUpdate be called multiple times per frame?

In Unity, sometimes FixedUpdate is called more than once during a single frame. Why does this happen?

ABecause the fixed timestep is longer than the frame time, so FixedUpdate is skipped
BBecause the frame rate is lower than the fixed timestep rate, so FixedUpdate runs multiple times to catch up
CBecause the frame rate is higher than the fixed timestep rate
DBecause FixedUpdate is called randomly by Unity
Attempts:
2 left
💡 Hint

Think about how Unity keeps physics simulation in sync with real time.