0
0
Unityframework~15 mins

Physics materials (friction, bounce) in Unity - Deep Dive

Choose your learning style9 modes available
Overview - Physics materials (friction, bounce)
What is it?
Physics materials in Unity define how surfaces interact when they touch or collide. They control properties like friction, which slows down movement, and bounce, which makes objects rebound after hitting each other. These materials help make game physics feel real and responsive. Without them, objects would slide endlessly or never bounce, breaking immersion.
Why it matters
Physics materials solve the problem of making object interactions believable and natural in games. Without friction, objects would unrealistically slide forever, and without bounce, collisions would feel dull and lifeless. This affects gameplay, player experience, and the overall feel of the virtual world. Realistic physics materials help players trust and enjoy the game environment.
Where it fits
Before learning physics materials, you should understand Unity's basic physics system, including Rigidbody and Colliders. After mastering physics materials, you can explore advanced physics behaviors like joints, forces, and custom physics scripting to create complex interactions.
Mental Model
Core Idea
Physics materials tell Unity how surfaces behave when they touch, controlling sliding and bouncing to make collisions feel real.
Think of it like...
Imagine sliding a book on a wooden table versus a glass table. The rough wood slows the book down (friction), while a rubber ball bouncing on the floor springs back up (bounce). Physics materials in Unity mimic these real-world surface behaviors.
┌───────────────┐       ┌───────────────┐
│   Surface A   │──────▶│   Surface B   │
│ (Physics Mat) │       │ (Physics Mat) │
└───────────────┘       └───────────────┘
         │                      │
         │ Friction & Bounce     │
         └─────────┬────────────┘
                   ▼
           ┌─────────────────┐
           │ Collision Event │
           └─────────────────┘
                   │
                   ▼
          ┌───────────────────┐
          │ Movement Behavior │
          │ (Slide, Bounce)   │
          └───────────────────┘
Build-Up - 7 Steps
1
FoundationWhat Are Physics Materials
🤔
Concept: Introduce the basic idea of physics materials as surface properties in Unity.
In Unity, physics materials are assets you create and assign to colliders. They define how surfaces react when they touch, mainly through friction and bounce. Friction controls how much objects slow down when sliding against each other. Bounce controls how much energy is returned after a collision, making objects rebound.
Result
You understand that physics materials are simple assets that change how objects slide and bounce in Unity.
Knowing that physics materials are separate assets helps you see them as customizable surface behaviors, not just fixed physics rules.
2
FoundationFriction Explained Simply
🤔
Concept: Explain friction as the force that resists sliding between surfaces.
Friction in physics materials has two parts: dynamic friction and static friction. Static friction stops objects from starting to slide. Dynamic friction slows objects that are already sliding. Higher friction means more resistance and less sliding. For example, ice has low friction, so objects slide easily, while rubber has high friction, so objects stop quickly.
Result
You can predict how changing friction values affects object movement in Unity.
Understanding friction's two types clarifies why objects sometimes stick and sometimes slide, improving your control over game physics.
3
IntermediateBounce and Bounciness Factor
🤔Before reading on: do you think bounce makes objects bounce higher than their drop height? Commit to your answer.
Concept: Introduce bounce as the energy returned after a collision, controlled by the bounciness property.
Bounce, or bounciness, is a value from 0 to 1 that controls how much an object rebounds after hitting another surface. A value of 0 means no bounce (the object stops), and 1 means a perfect bounce with no energy loss (like a super ball). Real objects usually have values between these extremes. Unity also lets you set bounce combine modes to decide how two materials' bounciness mix during collisions.
Result
You can adjust bounce to make objects rebound realistically or behave like sticky surfaces.
Knowing bounce is about energy return helps you create lively or dampened collisions, enhancing game feel.
4
IntermediateAssigning Materials to Colliders
🤔Before reading on: do you think physics materials affect Rigidbody properties directly? Commit to your answer.
Concept: Show how to apply physics materials to colliders to affect object interactions.
In Unity, you assign physics materials to Collider components, like BoxCollider or SphereCollider. When two colliders with physics materials collide, Unity uses their friction and bounce settings to calculate the resulting movement. Rigidbody components control mass and forces but do not hold physics materials themselves.
Result
You can make objects slide or bounce differently by assigning materials to their colliders.
Understanding that physics materials belong to colliders, not rigidbodies, prevents confusion about where to set surface behaviors.
5
IntermediateCombine Modes for Friction and Bounce
🤔Before reading on: do you think Unity averages friction values or picks the highest when two materials collide? Commit to your answer.
Concept: Explain how Unity combines friction and bounce values from two colliding materials.
Unity offers combine modes for friction and bounce: Average, Minimum, Maximum, and Multiply. These modes decide how the two materials' values mix during collisions. For example, Average takes the mean, Minimum uses the smaller value, Maximum uses the larger, and Multiply multiplies the values. This lets you fine-tune how surfaces interact, like making a slippery floor with a sticky ball.
Result
You can control complex surface interactions by choosing the right combine mode.
Knowing combine modes lets you predict and design nuanced physics behaviors beyond simple values.
6
AdvancedPerformance Impact of Physics Materials
🤔Before reading on: do you think using many unique physics materials slows down the game? Commit to your answer.
Concept: Discuss how physics materials affect physics calculations and game performance.
Each unique physics material adds to Unity's physics calculations during collisions. Using many different materials can increase CPU load, especially in physics-heavy scenes. However, reusing materials and carefully tuning friction and bounce can optimize performance. Unity's PhysX engine efficiently handles materials but complex combinations or frequent changes can cause slowdowns.
Result
You understand the balance between realistic physics and game performance.
Knowing performance costs helps you design physics materials wisely to keep games smooth.
7
ExpertCustom Physics Materials and Scripting
🤔Before reading on: do you think you can change friction or bounce dynamically at runtime without replacing materials? Commit to your answer.
Concept: Explore advanced use of physics materials by modifying or swapping them via scripts during gameplay.
Unity allows you to change physics materials on colliders at runtime using scripts. You can swap materials to simulate wet surfaces or worn-out floors. Also, you can create custom materials with unique friction and bounce values programmatically. However, changing materials frequently can cause unexpected physics behavior if not managed carefully. Understanding this lets you create dynamic, responsive environments.
Result
You can create games where surface properties change in real time, adding depth and realism.
Knowing how to manipulate physics materials at runtime unlocks advanced gameplay mechanics and environmental effects.
Under the Hood
Unity uses the PhysX physics engine to calculate collisions and interactions. When two colliders with physics materials collide, PhysX reads their friction and bounce values. It applies friction forces to resist sliding and calculates bounce impulses to simulate energy return. The combine modes determine how the two materials' properties merge into a single effective value for the collision. These calculations happen every physics update frame, influencing object velocities and positions.
Why designed this way?
Physics materials were designed as separate assets to allow flexible reuse and easy tuning without changing code. The combine modes provide a simple yet powerful way to handle interactions between different surfaces. This design balances performance and realism, letting developers create diverse materials without complex custom physics code. Alternatives like hardcoding friction per object would be less flexible and harder to maintain.
┌───────────────┐      ┌───────────────┐
│ Collider A    │      │ Collider B    │
│ (Physics Mat) │      │ (Physics Mat) │
└──────┬────────┘      └──────┬────────┘
       │                       │
       │ Collision Detected    │
       └────────────┬──────────┘
                    │
          ┌─────────▼─────────┐
          │ Combine Friction & │
          │ Bounce Values      │
          └─────────┬─────────┘
                    │
          ┌─────────▼─────────┐
          │ PhysX Physics Calc │
          │ (Friction Force & │
          │ Bounce Impulse)   │
          └─────────┬─────────┘
                    │
          ┌─────────▼─────────┐
          │ Update Rigidbody  │
          │ Velocity & Position│
          └───────────────────┘
Myth Busters - 4 Common Misconceptions
Quick: Does setting bounce to 1 make an object bounce higher than it was dropped from? Commit to yes or no.
Common Belief:If bounce is 1, the object will bounce higher than its drop height.
Tap to reveal reality
Reality:Bounce of 1 means the object returns all its energy, bouncing back to the original height, but never higher.
Why it matters:Expecting bounce >1 causes confusion when objects don't gain energy, preventing realistic physics design.
Quick: Do physics materials affect Rigidbody mass or gravity? Commit to yes or no.
Common Belief:Physics materials change Rigidbody properties like mass or gravity effects.
Tap to reveal reality
Reality:Physics materials only affect surface interactions (friction and bounce), not Rigidbody mass or gravity.
Why it matters:Confusing these leads to wrong assumptions about how to control object movement and collisions.
Quick: When two materials collide, does Unity always pick the higher friction value? Commit to yes or no.
Common Belief:Unity always uses the higher friction value between two materials during collisions.
Tap to reveal reality
Reality:Unity uses the selected combine mode (Average, Minimum, Maximum, Multiply) to calculate effective friction.
Why it matters:Assuming always max friction can cause unexpected sliding or sticking behavior in games.
Quick: Can you change friction or bounce values directly on a Rigidbody component? Commit to yes or no.
Common Belief:You can set friction and bounce directly on Rigidbody components.
Tap to reveal reality
Reality:Friction and bounce are set on physics materials assigned to colliders, not on Rigidbody components.
Why it matters:Misplacing settings causes confusion and wasted time troubleshooting physics behavior.
Expert Zone
1
Friction combine modes can cause subtle effects like objects sticking or sliding unexpectedly depending on material order and mode.
2
Changing physics materials at runtime requires careful synchronization to avoid physics glitches or jitter.
3
PhysX internally clamps friction and bounce values to maintain stable simulations, so extreme values may not behave as expected.
When NOT to use
Physics materials are not suitable for simulating complex surface effects like wetness or temperature changes that affect friction dynamically; in such cases, use custom physics scripts or shaders. Also, for non-physical visual effects, physics materials are unnecessary.
Production Patterns
In production, developers create reusable physics material libraries for common surfaces (metal, wood, rubber) and use combine modes strategically to simulate mixed surfaces. Dynamic swapping of materials is used for gameplay effects like ice patches or sticky traps. Performance profiling guides minimizing unique materials to keep physics efficient.
Connections
Coefficient of Friction (Physics)
Physics materials implement the coefficient of friction concept from classical physics.
Understanding real-world friction coefficients helps tune Unity materials for believable surface interactions.
Energy Conservation (Physics)
Bounce in physics materials models energy conservation during collisions.
Knowing energy conservation principles clarifies why bounce values range between 0 and 1 and never exceed 1.
Material Science
Physics materials abstract real material properties like roughness and elasticity.
Appreciating how real materials behave guides creating realistic game surfaces and interactions.
Common Pitfalls
#1Assigning physics materials to Rigidbody instead of Collider.
Wrong approach:rigidbody.physicsMaterial = myMaterial;
Correct approach:collider.material = myMaterial;
Root cause:Misunderstanding that physics materials belong to colliders, not rigidbodies.
#2Setting bounce above 1 to get higher bounces.
Wrong approach:myMaterial.bounciness = 1.5f;
Correct approach:myMaterial.bounciness = 1.0f; // Max allowed value
Root cause:Misconception that bounce can increase energy beyond initial input.
#3Expecting friction to stop objects instantly with low values.
Wrong approach:myMaterial.dynamicFriction = 0.0f; // Expect object to stop quickly
Correct approach:myMaterial.dynamicFriction = 1.0f; // High friction to stop sliding
Root cause:Confusing friction direction and effect; low friction means less resistance.
Key Takeaways
Physics materials in Unity control how surfaces slide and bounce during collisions, making interactions feel real.
Friction has static and dynamic parts that affect starting and continuing sliding differently.
Bounce controls how much energy returns after a collision, with values between 0 (no bounce) and 1 (perfect bounce).
Physics materials are assigned to colliders, not rigidbodies, and their properties combine during collisions based on chosen modes.
Advanced use includes runtime material swapping and careful performance considerations to create dynamic and efficient physics behaviors.