Performance: Rigidbody 3D component
MEDIUM IMPACT
This affects the physics simulation performance and frame rate smoothness in a 3D game scene.
foreach (var obj in objects) { if (obj.needsPhysics) { obj.AddComponent<Rigidbody>(); obj.mass = 1; obj.useGravity = true; } }
foreach (var obj in objects) { obj.AddComponent<Rigidbody>(); obj.mass = 1; obj.useGravity = true; }
| Pattern | Physics Calculations | CPU Load | Frame Rate Impact | Verdict |
|---|---|---|---|---|
| Adding Rigidbody to all objects | High (all objects simulated) | High | Significant frame drops | [X] Bad |
| Adding Rigidbody only to needed objects | Low (filtered simulation) | Low | Smooth frame rate | [OK] Good |