Bird
Raised Fist0
Unityframework~15 mins

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

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
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.

Practice

(1/5)
1. What does a Physics Material in Unity primarily control?
easy
A. The size of a collider
B. The color of a game object
C. The speed of a Rigidbody
D. Friction and bounce behavior of colliders

Solution

  1. Step 1: Understand the role of Physics Materials

    Physics Materials are used to define how surfaces interact physically, mainly controlling friction and bounce.
  2. Step 2: Identify what Physics Materials affect

    They affect colliders by changing friction (slipperiness or stickiness) and bounce (how much objects rebound).
  3. Final Answer:

    Friction and bounce behavior of colliders -> Option D
  4. Quick Check:

    Physics Material = friction and bounce control [OK]
Hint: Physics Materials change friction and bounce, not visuals [OK]
Common Mistakes:
  • Confusing Physics Material with visual materials
  • Thinking it controls Rigidbody speed
  • Assuming it changes collider size
2. Which of the following is the correct way to assign a Physics Material to a Collider in Unity using C#?
easy
A. collider.material = myPhysicsMaterial;
B. collider.physicsMaterial = myPhysicsMaterial;
C. collider.physicMaterial = myPhysicsMaterial;
D. collider.physicsMaterial2D = myPhysicsMaterial;

Solution

  1. Step 1: Recall the correct property name for Physics Material

    In Unity, the Collider component uses the property 'material' to assign a Physics Material.
  2. Step 2: Check the options for correct syntax

    collider.material = myPhysicsMaterial; uses 'collider.material', which is correct. Other options use incorrect property names or 2D-specific properties.
  3. Final Answer:

    collider.material = myPhysicsMaterial; -> Option A
  4. Quick Check:

    Collider.material assigns Physics Material [OK]
Hint: Use collider.material to assign Physics Material [OK]
Common Mistakes:
  • Using 'physicsMaterial' instead of 'material'
  • Confusing 3D and 2D collider properties
  • Misspelling 'physicMaterial'
3. Consider the following C# code in Unity:
PhysicsMaterial2D bouncyMaterial = new PhysicsMaterial2D();
bouncyMaterial.bounciness = 1.0f;
Collider2D col = gameObject.GetComponent<Collider2D>();
col.sharedMaterial = bouncyMaterial;

Rigidbody2D rb = gameObject.GetComponent<Rigidbody2D>();
rb.velocity = new Vector2(0, -10);
What will happen when this object hits the ground?
medium
A. It will bounce back with the same speed it hit the ground
B. It will stick to the ground without bouncing
C. It will bounce but lose some speed
D. It will ignore collisions and pass through the ground

Solution

  1. Step 1: Analyze the Physics Material bounciness

    The bouncyMaterial has bounciness set to 1.0, which means full bounce with no energy loss.
  2. Step 2: Understand the effect on collision

    Assigning this material to the collider means the object will bounce back with the same speed it hit the ground.
  3. Final Answer:

    It will bounce back with the same speed it hit the ground -> Option A
  4. Quick Check:

    Bounciness 1.0 means full bounce [OK]
Hint: Bounciness 1 means full bounce, no speed lost [OK]
Common Mistakes:
  • Assuming bounciness 1.0 means no bounce
  • Confusing sharedMaterial with material
  • Ignoring Rigidbody velocity effect
4. You wrote this code to make an object slippery:
PhysicsMaterial2D slippery = new PhysicsMaterial2D();
slippery.friction = 0f;
Collider2D col = gameObject.GetComponent<Collider2D>();
col.material = slippery;
But the object still slides slowly. What is the likely mistake?
medium
A. You should set bounciness to 0 instead of friction
B. You assigned the material to 'col.material' instead of 'col.sharedMaterial'
C. The Rigidbody2D's linear drag is causing slow sliding
D. Physics Materials do not affect friction

Solution

  1. Step 1: Check the property used for assignment

    Collider2D uses sharedMaterial property to assign PhysicsMaterial2D, not material which does not exist on Collider2D.
  2. Step 2: Understand the consequence

    Using the wrong property means the custom material with friction=0 is not assigned; default material with friction >0 is used, causing slow sliding.
  3. Final Answer:

    You assigned the material to 'col.material' instead of 'col.sharedMaterial' -> Option B
  4. Quick Check:

    Collider2D.sharedMaterial is the correct property [OK]
Hint: Collider2D: use sharedMaterial, not material [OK]
Common Mistakes:
  • Thinking friction 0 disables all slowing forces
  • Confusing material and sharedMaterial assignment
  • Believing Physics Materials don't affect friction
5. You want to create a bouncy ball that loses some energy on each bounce and slides slowly on the floor. Which settings for Physics Material friction and bounciness should you use?
hard
A. friction = 1.0, bounciness = 1.0
B. friction = 0, bounciness = 1.0
C. friction = 0.8, bounciness = 0.5
D. friction = 0.2, bounciness = 0

Solution

  1. Step 1: Understand desired bounce behavior

    The ball should bounce but lose some energy, so bounciness should be less than 1, e.g., 0.5.
  2. Step 2: Understand desired sliding behavior

    To slide slowly, friction should be moderate to high, e.g., 0.8, to resist sliding.
  3. Final Answer:

    friction = 0.8, bounciness = 0.5 -> Option C
  4. Quick Check:

    Moderate friction and bounciness = slow slide + partial bounce [OK]
Hint: Use moderate friction and bounciness for slow slide and partial bounce [OK]
Common Mistakes:
  • Using zero friction causes too much sliding
  • Using bounciness 1.0 causes full bounce with no energy loss
  • Confusing friction and bounciness values