Unity Physics: Rigidbody AddForce vs. linearVelocity
05 Aug 26 (1mo ago)
When building movement mechanics in Unity, the choice between Rigidbody.AddForce and Rigidbody.linearVelocity (formerly velocity) dictates the entire "feel" of your game. The decision boils down to one core question: do you need physics-driven momentum or tight, arcade-style control?
Rigidbody.AddForce: The Physics-First Approach
AddForce applies an impulse or continuous force that the physics engine integrates over time. This approach respects the object's mass ($F=ma$) and allows multiple forces (like gravity, friction, and wind) to combine naturally within the simulation.
- Best for: Vehicles, pushing/pulling heavy objects, explosions, wind effects, and physics-based jumping (
ForceMode.Impulse). - Pros: Plays perfectly with Unity’s physics engine. Forces stack seamlessly without overriding each other.
- Cons: Can feel "floaty" or sluggish for precise character movement due to the natural time it takes to accelerate and decelerate.
Rigidbody.linearVelocity: The Arcade Approach
linearVelocity strictly overrides the object's current velocity vector. You are instructing the physics engine to ignore momentum and instantly move the object at a defined speed.
- Best for: Platformer character movement, fast-paced projectiles, and classic arcade games.
- Pros: Extremely responsive, tight, and predictable.
- Cons: Ignores mass and acceleration. Overwriting velocity every frame can unintentionally cancel out other critical physical forces—like gravity or impact knockbacks—if implemented incorrectly.
Quick Comparison
| Feature | AddForce | linearVelocity |
|---|---|---|
| Feel | Natural, weight-based, momentum-heavy | Snappy, instant, arcade-like |
| Control | Indirect (influences motion) | Direct (dictates motion) |
| Physics | Cumulative (stackable forces) | Overrides existing motion |
| Ideal Use | Environment physics, heavy objects, vehicles | Character controllers, projectiles |
The CharacterController Connection
If you are accustomed to Unity's CharacterController component, linearVelocity is its closest physical equivalent. Both approaches are fundamentally directive: you specify exactly how fast the character should move, and they respond immediately, completely bypassing the sliding associated with AddForce.
The major difference is that a Rigidbody using linearVelocity still interacts natively with the physics world. Hitting a wall will physically stop or bounce the player, and Unity's global gravity will still pull the object down. The CharacterController, on the other hand, is essentially "kinematic-lite"—it ignores mass and gravity unless you manually code them, and requires custom handling for collisions.
Pro Tip: Preserving Gravity in C#
A common pitfall when updating linearVelocity every frame is accidentally setting the vertical velocity to zero, which effectively turns off gravity. To get snappy horizontal movement while letting the physics engine handle falling, always preserve the existing Y-axis velocity.
// The correct way to apply snappy horizontal movement while preserving gravity
rb.linearVelocity = new Vector2(inputX * moveSpeed, rb.linearVelocity.y);