0
0
Unityframework~8 mins

Physics materials (friction, bounce) in Unity - Performance & Optimization

Choose your learning style9 modes available
Performance: Physics materials (friction, bounce)
MEDIUM IMPACT
This affects the physics simulation performance and the smoothness of object interactions in the game.
Applying physics materials to control friction and bounce on game objects
Unity
var sharedMat = Resources.Load<PhysicMaterial>("SharedMaterial");
collider.material = sharedMat; // reuse one shared material
Reusing a shared physics material reduces memory and CPU overhead by avoiding duplicate data and recalculations.
📈 Performance GainReduces CPU load and memory usage, improving frame rate with many physics objects
Applying physics materials to control friction and bounce on game objects
Unity
var mat = new PhysicMaterial();
mat.dynamicFriction = 1.0f;
mat.staticFriction = 1.0f;
mat.bounciness = 1.0f;
collider.material = mat; // creating new material per object
Creating a new physics material instance for every object causes unnecessary memory use and CPU overhead during physics calculations.
📉 Performance CostIncreases CPU usage and memory, causing slower physics updates especially with many objects
Performance Comparison
PatternPhysics CalculationsMemory UsageCPU LoadVerdict
Unique material per objectHigh (many calculations)High (many instances)High (complex friction/bounce)[X] Bad
Shared physics materialLow (shared calculations)Low (single instance)Low (simple reuse)[OK] Good
Rendering Pipeline
Physics materials influence the physics engine's collision response calculations before rendering updates the visuals.
Physics Simulation
Collision Detection
Game Loop Update
⚠️ BottleneckPhysics Simulation stage is most expensive due to friction and bounce calculations.
Optimization Tips
1Reuse physics materials instead of creating new ones per object.
2Keep friction and bounce values simple to reduce physics CPU load.
3Use Unity Profiler to monitor physics CPU usage and optimize accordingly.
Performance Quiz - 3 Questions
Test your performance knowledge
What is the main performance cost of using many unique physics materials with different friction and bounce values?
AIncreased CPU load due to more physics calculations
BSlower rendering of textures
CMore GPU memory usage
DLonger script compilation time
DevTools: Profiler
How to check: Open Unity Profiler, run the game scene, and look at the Physics section to see CPU time spent on collision and friction calculations.
What to look for: High CPU time in Physics indicates expensive friction/bounce calculations; lower values mean better performance.