Unity Physics: Using Physic Materials

Jared Amlin
Nerd For Tech

--

When working with physics behaviors in Unity you may find yourself in need of Physics Materials. When it comes to bouncing balls, slippery ice, or sticky surfaces, physics materials have you covered!

Scene Setup

This scene has a metal cube dropping on to a metal ramp that is sloped downwards. I would think this object should be able to slide down the ramp with those two semi-smooth surfaces. A few physics materials will take care of this problem, so let’s create some by navigating to Create>Physic Material.

Four physics materials have been created for this example.

The metal box gets the metal physics material.

The metal ramp gets the smooth metal physics material.

And this sphere primitive uses the bouncing ball physics material.

To assign a physics material to an object, drag it into the Material assignment slot in the object’s collider.

Physic Material

Let’s take a look at some of the values we can adjust on the physic material. In most cases, your dynamic friction value will be lower than your static friction value, being that objects already in motion will have lower friction and are easier to keep moving. The static friction value is typically higher, because you need more force to break a stationary object free and get it moving.

Here are some descriptions from the Unity documentation.

Dynamic Friction: Define how much friction the collider’s surface has against another collider when the colliders are moving or sliding against each other. This value is between 0 and 1. A value of 0 means no friction (like ice), while a value of 1 means very high friction (like rubber). By default, Dynamic Friction is set to 0.6.

Static Friction: Define how much friction the collider’s surface has against another collider when the colliders are not moving. This value is between 0 and 1. A value of 0 means no friction (like ice), while a value of 1 means very high friction (like rubber). By default, Static Friction is set to 0.6.

The Bounciness value seems pretty self-explanatory. A value of 1 will make the object bounce infinitely, so for more realistic simulations a lower value is needed.

The Friction and Bounce Combine options are set to Average by default, which uses the average value between the two physic materials that are colliding.

This simulation is bouncing with the average from the ball material and the floor materials. I’m not sure how bouncy hard surfaced floors are supposed to be, but we can use these Combine settings to get more bounce out of the ball.

By setting the Bounce Combine to Maximum, the ball will use the highest value between the two colliding objects. In this case that will be the ball itself with a high bounce value of 0.9.

The ball is much more bouncy in this simulation.

The different Combine options include average, maximum, minimum and multiply. While average is the default, you may need to use one of the others for more specific behaviors.

The metal has a low static friction. It’s not as slick as ice, but it should be able to slide down the ramp.

The smooth metal is even smoother.

There goes the box sliding into it’s new home!

I hope you enjoyed this quick trip into physic materials in Unity and thanks for reading!

--

--

Jared Amlin
Nerd For Tech

I am an artist and musician, that is currently diving headfirst into game development with C# and Unity3D.