Course contentsShow
← Unity Game Development
Lesson 163 of 8283. Physics and InteractionFree lesson

Creating Custom Physics Materials for Surface Friction

Design and apply Physics Materials to adjust friction and bounciness properties for diverse environmental surfaces like ice or rubber.

In this lesson, you will learn how to use Physics Materials to override default surface properties, allowing you to create surfaces like slippery ice or high-grip rubber.

Understanding Physics Materials

By default, Unity applies a standard set of physical rules to all colliders. However, if you want a floor to feel like a skating rink or a bouncing ball to act more like a heavy lead weight, you need a Physic Material. This asset acts as a modifier for the friction and bounciness of any collider it is attached to.

Creating and Applying the Material

To get started, right-click in your Project window and select Create > Physic Material. Once created, you will see two primary settings:

  • Dynamic Friction: How much the object resists sliding while it is already in motion.
  • Static Friction: How much force is required to get an object to start moving from a standstill.
  • Bounciness: How much energy is retained during a collision.

Once you have tweaked these values, you simply drag and drop the Physic Material asset directly onto the Material slot found inside the Collider component (like a BoxCollider or SphereCollider) of your GameObject.

Handling Friction Combinations

When two objects collide, they might both have different Physics Materials. Unity determines the final behavior using the Friction Combine and Bounce Combine settings. These settings define whether Unity should take the Average, Minimum, Maximum, or Multiply the two values together. For example, if you set your ice material to Minimum, it will ensure that if the player hits "ice," they will slip regardless of what the other object is made of.

// You can also assign these via script if needed:
public PhysicMaterial iceMaterial;

void Start() {
    GetComponent<Collider>().material = iceMaterial;
}

By fine-tuning these settings, you gain granular control over how your player moves across your environment without needing to write custom movement scripts for every surface type.

Key Takeaway: Physics Materials allow you to simulate diverse material behaviors by overriding friction and bounciness values directly within the Collider component.