Bird
Raised Fist0
Unityframework~20 mins

Rigidbody forces and velocity in Unity - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
šŸŽ–ļø
Rigidbody Force Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ā“ Predict Output
intermediate
2:00remaining
What is the velocity after applying force with ForceMode.Force?
Consider a Rigidbody with mass 2 kg initially at rest. You apply a force of (4, 0, 0) using ForceMode.Force for one fixed update frame. What will be the velocity of the Rigidbody after this frame?
Unity
Rigidbody rb = GetComponent<Rigidbody>();
rb.mass = 2f;
rb.velocity = Vector3.zero;
Vector3 force = new Vector3(4f, 0f, 0f);
rb.AddForce(force, ForceMode.Force);
// Assume fixedDeltaTime = 0.02 seconds
AVelocity will be (0.04, 0, 0)
BVelocity will be (2, 0, 0)
CVelocity will be (4, 0, 0)
DVelocity will be (0.02, 0, 0)
Attempts:
2 left
šŸ’” Hint
Remember ForceMode.Force applies force over time, so velocity changes by acceleration * deltaTime.
ā“ Predict Output
intermediate
2:00remaining
What is the velocity after applying force with ForceMode.Impulse?
A Rigidbody with mass 3 kg is at rest. You apply an impulse force of (6, 0, 0) using ForceMode.Impulse. What is the velocity immediately after applying this impulse?
Unity
Rigidbody rb = GetComponent<Rigidbody>();
rb.mass = 3f;
rb.velocity = Vector3.zero;
Vector3 impulse = new Vector3(6f, 0f, 0f);
rb.AddForce(impulse, ForceMode.Impulse);
AVelocity will be (2, 0, 0)
BVelocity will be (0, 0, 0)
CVelocity will be (6, 0, 0)
DVelocity will be (0.02, 0, 0)
Attempts:
2 left
šŸ’” Hint
Impulse changes velocity immediately by impulse / mass.
šŸ”§ Debug
advanced
2:00remaining
Why does velocity not change after AddForce with ForceMode.Acceleration?
You have this code snippet: Rigidbody rb = GetComponent(); rb.velocity = Vector3.zero; rb.AddForce(new Vector3(10, 0, 0), ForceMode.Acceleration); But after running, velocity remains zero. What is the most likely reason?
Unity
Rigidbody rb = GetComponent<Rigidbody>();
rb.velocity = Vector3.zero;
rb.AddForce(new Vector3(10, 0, 0), ForceMode.Acceleration);
AForceMode.Acceleration requires mass to be zero to work.
BThe Rigidbody is set to kinematic, so forces don't affect velocity.
CAddForce with ForceMode.Acceleration only works in FixedUpdate, not Update.
DVelocity is reset to zero immediately after AddForce.
Attempts:
2 left
šŸ’” Hint
Check Rigidbody settings that disable physics simulation.
🧠 Conceptual
advanced
2:00remaining
How does ForceMode.VelocityChange differ from ForceMode.Impulse?
Which statement correctly describes the difference between ForceMode.VelocityChange and ForceMode.Impulse when applied to a Rigidbody?
ABoth apply force ignoring mass but at different time intervals.
BVelocityChange applies a continuous force; Impulse applies a one-time force.
CImpulse ignores mass and changes velocity directly; VelocityChange applies force considering mass.
DVelocityChange ignores mass and changes velocity directly; Impulse applies force considering mass.
Attempts:
2 left
šŸ’” Hint
Think about how mass affects velocity change in each mode.
ā“ Predict Output
expert
3:00remaining
What is the final velocity after multiple AddForce calls with different ForceModes?
A Rigidbody with mass 4 kg starts at zero velocity. The following code runs in one FixedUpdate: rb.AddForce(new Vector3(8, 0, 0), ForceMode.Force); rb.AddForce(new Vector3(4, 0, 0), ForceMode.Impulse); rb.AddForce(new Vector3(2, 0, 0), ForceMode.VelocityChange); Assuming fixedDeltaTime = 0.02 seconds, what is the final velocity vector?
Unity
Rigidbody rb = GetComponent<Rigidbody>();
rb.mass = 4f;
rb.velocity = Vector3.zero;
rb.AddForce(new Vector3(8f, 0f, 0f), ForceMode.Force);
rb.AddForce(new Vector3(4f, 0f, 0f), ForceMode.Impulse);
rb.AddForce(new Vector3(2f, 0f, 0f), ForceMode.VelocityChange);
AVelocity will be (4.02, 0, 0)
BVelocity will be (3.5, 0, 0)
CVelocity will be (3.04, 0, 0)
DVelocity will be (1.5, 0, 0)
Attempts:
2 left
šŸ’” Hint
Calculate velocity changes from each AddForce separately and sum them.

Practice

(1/5)
1. In Unity, what is the main difference between applying a force to a Rigidbody and setting its velocity directly?
easy
A. Applying a force stops the Rigidbody immediately, setting velocity makes it float.
B. Applying a force changes the Rigidbody's color, setting velocity changes its size.
C. Applying a force disables gravity, setting velocity enables gravity.
D. Applying a force changes velocity gradually, setting velocity changes it instantly.

Solution

  1. Step 1: Understand force effect on Rigidbody

    Applying a force adds acceleration, so velocity changes smoothly over time.
  2. Step 2: Understand velocity setting

    Setting velocity directly changes speed and direction immediately without gradual acceleration.
  3. Final Answer:

    Applying a force changes velocity gradually, setting velocity changes it instantly. -> Option D
  4. Quick Check:

    Force = gradual change, velocity = instant change [OK]
Hint: Force pushes smoothly; velocity sets speed instantly [OK]
Common Mistakes:
  • Thinking force stops the object immediately
  • Confusing force with color or size changes
  • Believing velocity affects gravity
2. Which of the following is the correct way to add an upward force to a Rigidbody named rb in Unity?
easy
A. rb.AddForce(Vector3.up * 10);
B. rb.AddForce(10, Vector3.up);
C. rb.AddForce(10);
D. rb.AddForceUp(10);

Solution

  1. Step 1: Check AddForce method signature

    Unity's Rigidbody.AddForce expects a Vector3 representing force direction and magnitude.
  2. Step 2: Verify correct usage

    Using Vector3.up * 10 applies force upwards with magnitude 10, matching the method signature.
  3. Final Answer:

    rb.AddForce(Vector3.up * 10); -> Option A
  4. Quick Check:

    AddForce(Vector3) is correct syntax [OK]
Hint: AddForce needs Vector3 direction and magnitude [OK]
Common Mistakes:
  • Passing separate arguments instead of a Vector3
  • Using non-existent methods like AddForceUp
  • Passing only a number without direction
3. Consider this Unity C# code snippet:
Rigidbody rb = GetComponent<Rigidbody>();
rb.velocity = new Vector3(0, 5, 0);
rb.AddForce(new Vector3(0, 10, 0), ForceMode.Acceleration);
What will be the Rigidbody's velocity immediately after these lines run?
medium
A. Velocity will be (0, 5, 0) and then increase gradually.
B. Velocity will be (0, 10, 0) instantly.
C. Velocity will be (0, 15, 0) instantly.
D. Velocity will be (0, 0, 0) because forces cancel velocity.

Solution

  1. Step 1: Analyze velocity assignment

    Setting rb.velocity to (0,5,0) sets speed instantly upward at 5 units per second.
  2. Step 2: Analyze AddForce with Acceleration mode

    AddForce with ForceMode.Acceleration adds acceleration, so velocity increases gradually over time, not instantly.
  3. Final Answer:

    Velocity will be (0, 5, 0) and then increase gradually. -> Option A
  4. Quick Check:

    Velocity set instantly; force adds gradual acceleration [OK]
Hint: Velocity sets speed instantly; force adds gradual acceleration [OK]
Common Mistakes:
  • Assuming AddForce instantly changes velocity
  • Confusing ForceMode.Acceleration with ForceMode.VelocityChange
  • Thinking forces cancel velocity
4. What is wrong with this Unity C# code to move a Rigidbody upward?
Rigidbody rb = GetComponent<Rigidbody>();
rb.velocity += Vector3.up * 5;
medium
A. You cannot use '+=' operator with velocity; it causes errors.
B. This code instantly adds 5 units upward speed every frame, causing acceleration buildup.
C. Vector3.up is not a valid direction for velocity.
D. Rigidbody velocity cannot be changed directly.

Solution

  1. Step 1: Understand velocity += Vector3.up * 5

    This adds 5 units upward speed to current velocity instantly each time it runs.
  2. Step 2: Identify problem in repeated calls

    If called every frame, velocity keeps increasing, causing unnatural acceleration buildup.
  3. Final Answer:

    This code instantly adds 5 units upward speed every frame, causing acceleration buildup. -> Option B
  4. Quick Check:

    Adding velocity each frame causes speed to grow too fast [OK]
Hint: Adding velocity each frame causes speed to grow too fast [OK]
Common Mistakes:
  • Thinking '+=' on velocity causes syntax errors
  • Believing Vector3.up is invalid
  • Assuming velocity cannot be changed directly
5. You want to make a Rigidbody jump smoothly using physics forces, but also limit its maximum upward speed to 10 units per second. Which approach correctly combines forces and velocity control?
hard
A. Use rb.AddForce(Vector3.up * jumpForce) only and ignore velocity limits.
B. Set rb.velocity = Vector3.up * 10 directly every frame without forces.
C. Use rb.AddForce(Vector3.up * jumpForce) and clamp rb.velocity.y to max 10 after applying force.
D. Set rb.velocity = Vector3.up * jumpForce once and never apply forces.

Solution

  1. Step 1: Use AddForce for smooth jumping

    Applying AddForce lets physics handle smooth acceleration for jump.
  2. Step 2: Clamp velocity to limit max speed

    After applying force, clamp rb.velocity.y to 10 to prevent exceeding max upward speed.
  3. Final Answer:

    Use rb.AddForce(Vector3.up * jumpForce) and clamp rb.velocity.y to max 10 after applying force. -> Option C
  4. Quick Check:

    Force for smooth jump + clamp velocity to limit speed [OK]
Hint: Combine AddForce with velocity clamp to control max speed [OK]
Common Mistakes:
  • Setting velocity directly every frame causing unnatural jumps
  • Ignoring velocity limits causing excessive speed
  • Using only velocity without forces for smooth physics