# 5. Forces, FixedUpdate, and Motion Modes
Part of [[Physics 3D]]. Previous: [[4. Joints]]. Next: [[6. Worked Example Pushable Prop]].
**Docs:** [Rigidbody intro](https://docs.unity3d.com/6000.5/Documentation/Manual/RigidbodiesOverview.html) · Force APIs on `Rigidbody` Scripting Reference for your Editor
## 5.1 FixedUpdate is the physics heartbeat
| Callback | Cadence | Put here |
|---|---|---|
| `FixedUpdate` | Fixed Timestep (default 0.02s) | `AddForce`, `AddTorque`, physics velocity changes |
| `Update` | Frame rate | Input sampling, visuals, animation parameters |
| `LateUpdate` | After Update | Camera follow |
Read input in `Update` (or Input System callbacks — [[Input System]]), **apply** forces in `FixedUpdate`. Pattern discussion: [[Game Programming Patterns (Review)]] (Update Method).
```csharp
using UnityEngine;
using UnityEngine.InputSystem;
[RequireComponent(typeof(Rigidbody))]
public class ForceMover : MonoBehaviour
{
[SerializeField] float acceleration = 20f;
[SerializeField] InputAction moveAction;
Rigidbody _rb;
Vector2 _move;
void Awake() => _rb = GetComponent<Rigidbody>();
void OnEnable()
{
moveAction.Enable();
moveAction.performed += ctx => _move = ctx.ReadValue<Vector2>();
moveAction.canceled += _ => _move = Vector2.zero;
}
void OnDisable() => moveAction.Disable();
void FixedUpdate()
{
Vector3 wish = new Vector3(_move.x, 0f, _move.y);
if (wish.sqrMagnitude > 1f) wish.Normalize();
_rb.AddForce(wish * acceleration, ForceMode.Acceleration);
}
}
```
> [!warning] Code not compiled in Unity
> Not compiled in Editor for this write-up.
## 5.2 ForceMode cheatsheet
| Mode | Meaning |
|---|---|
| `Force` | Continuous force; mass matters (`F = ma`) |
| `Acceleration` | Ignore mass; pure acceleration |
| `Impulse` | Instant velocity change scaled by mass (jumps, explosions) |
| `VelocityChange` | Instant velocity change **ignoring** mass |
Explosions: `AddExplosionForce`. Vehicles: often torques + specialized WheelColliders ([[Car Controller]]).
## 5.3 Dynamic vs kinematic motion
| Mode | Drive with | Collisions |
|---|---|---|
| **Dynamic** (`isKinematic = false`) | Forces / torques / careful velocity | Full solver response |
| **Kinematic** | `MovePosition` / `MoveRotation` or Transform + `Physics.SyncTransforms` | Pushes dynamics; not pushed |
```csharp
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class KinematicPlatform : MonoBehaviour
{
[SerializeField] Vector3 peakOffset = new Vector3(0f, 2f, 0f);
[SerializeField] float period = 3f;
Rigidbody _rb;
Vector3 _start;
void Awake()
{
_rb = GetComponent<Rigidbody>();
_rb.isKinematic = true;
_rb.interpolation = RigidbodyInterpolation.Interpolate;
_start = _rb.position;
}
void FixedUpdate()
{
float t = (Mathf.Sin((Time.time / period) * Mathf.PI * 2f) + 1f) * 0.5f;
_rb.MovePosition(_start + peakOffset * t);
}
}
```
> [!warning] Code not compiled in Unity
> Not compiled in Editor for this write-up.
Moving a kinematic platform with raw `transform.position` every frame is a common sleep/tunnel footgun — prefer `MovePosition` in `FixedUpdate`.
## 5.4 Root motion vs physics
Animator **root motion** writes motion from clips ([[Animation]] part 4). Mixing root motion and dynamic Rigidbody on the same object without a clear owner causes foot slide / fighting. Patterns:
- Kinematic Character Controller style: kinematic body + manual depenetration queries ([[3. Layers Matrix and Queries]]).
- Fully physics character: no root motion displacement; animation follows velocity.
- Hybrid: apply root motion as velocity suggestions carefully (advanced — test per archetype).
Omnidirectional / surface walking notes: [[Surface-Walking with an Omnidirectional Player Movement]].
## 5.5 Setting velocity directly
```csharp
_rb.linearVelocity = new Vector3(wish.x, _rb.linearVelocity.y, wish.z);
```
Useful for tight arcade control; bypasses some acceleration feel. Respect Unity 6 naming (`linearVelocity` vs obsolete `velocity` — confirm on your Scripting Reference).
## Next
[[6. Worked Example Pushable Prop]] — character + crate interaction lab.