Performance: Physics materials (friction, bounce)
MEDIUM IMPACT
This affects the physics simulation performance and the smoothness of object interactions in the game.
var sharedMat = Resources.Load<PhysicMaterial>("SharedMaterial");
collider.material = sharedMat; // reuse one shared materialvar mat = new PhysicMaterial(); mat.dynamicFriction = 1.0f; mat.staticFriction = 1.0f; mat.bounciness = 1.0f; collider.material = mat; // creating new material per object
| Pattern | Physics Calculations | Memory Usage | CPU Load | Verdict |
|---|---|---|---|---|
| Unique material per object | High (many calculations) | High (many instances) | High (complex friction/bounce) | [X] Bad |
| Shared physics material | Low (shared calculations) | Low (single instance) | Low (simple reuse) | [OK] Good |