0
0
Unityframework~30 mins

FixedUpdate vs Update in Unity - Hands-On Comparison

Choose your learning style9 modes available
FixedUpdate vs Update in Unity
📖 Scenario: You are making a simple Unity game where a ball moves based on player input. You want to understand how to use Update and FixedUpdate methods correctly to move the ball smoothly and with proper physics.
🎯 Goal: Build a Unity script that moves a ball using Update for input reading and FixedUpdate for applying physics movement.
📋 What You'll Learn
Create a Rigidbody variable to control the ball's physics
Use Update to read horizontal input into a variable
Use FixedUpdate to apply movement to the Rigidbody
Print messages in both Update and FixedUpdate to see when they run
💡 Why This Matters
🌍 Real World
Games often need smooth and realistic movement. Using <code>Update</code> and <code>FixedUpdate</code> correctly helps make player controls responsive and physics stable.
💼 Career
Understanding Unity's update methods is essential for game developers to create smooth gameplay and avoid bugs related to physics and input timing.
Progress0 / 4 steps
1
Setup Rigidbody variable
Create a public Rigidbody variable called rb inside the BallController class.
Unity
Need a hint?

Use public Rigidbody rb; inside the class.

2
Read input in Update
Add a private float variable called horizontalInput. In the Update method, set horizontalInput to Input.GetAxis("Horizontal"). Also, add a Debug.Log statement inside Update that prints "Update called".
Unity
Need a hint?

Use Input.GetAxis("Horizontal") to read left/right input.

3
Move Rigidbody in FixedUpdate
Add a FixedUpdate method. Inside it, create a Vector3 called movement with horizontalInput as the x value and 0 for y and z. Then call rb.MovePosition(rb.position + movement * 5f * Time.fixedDeltaTime). Also add a Debug.Log statement that prints "FixedUpdate called".
Unity
Need a hint?

Use rb.MovePosition inside FixedUpdate to move the ball smoothly with physics.

4
Print final messages
Add a print statement in Update that prints the current horizontalInput value. Add a print statement in FixedUpdate that prints the current rb.position.
Unity
Need a hint?

Use print with f-strings to show values in console.