Performance: Rigidbody forces and velocity
MEDIUM IMPACT
This concept affects the physics simulation performance and frame rendering smoothness in a Unity game.
void FixedUpdate() {
rigidbody.AddForce(new Vector3(5, 0, 0), ForceMode.Force);
}void Update() {
rigidbody.velocity = new Vector3(5, 0, 0);
}| Pattern | Physics Calls | Frame Updates | Jitter Risk | Verdict |
|---|---|---|---|---|
| Direct velocity set in Update | High (every frame) | High (every frame) | High | [X] Bad |
| AddForce in FixedUpdate | Moderate (fixed timestep) | Moderate (fixed timestep) | Low | [OK] Good |