Unity Physics — Physics Materials
Physics materials are an asset we can apply to a collider and give it physical properties. For example, we can add a physics material to a collider that will make it have the same physical properties as ice. By adjusting the friction value we can simulate what it would be like to glide along the surface.
To create a physics material, simply right click in your project view and select Physics Material.
Here I have a default physics material. I called it “Smooth.” Lets go over these properties real fast.
Dynamic Friction = The friction used when already moving. Usually a value from 0 to 1. A value of zero feels like ice, a value of 1 will make it come to rest very quickly unless a lot of force or gravity pushes the object.
Static Friction = The friction used when an object is laying still on a surface. Usually a value from 0 to 1. A value of zero feels like ice, a value of 1 will make it very hard to get the object moving.
Bounciness = How bouncy the surface is.
Friction Combine = How the friction of two colliding objects is combined.
There are a few different options here:
- Average = The two friction values are averaged.
- Minimum = The smallest of the two values is used.
- Maximum = The largest of the two values is used.
- Multiply = The friction values are multiplied with each other.
Bounciness Combine = How the bounciness of two colliding objects is combined. It has the same modes as Friction Combine Mode.
Took all this from the Unity Manual! Unity — Manual: Physic Material (unity3d.com)
So heres an example:
When I have this cube drop, look what happens.
If I want it to slide down the ramp, I’ll need to add a physics material to both and adjust the values to simulate the kind of physics I want to happen. Since these are both metallic objects, I won’t make it slide down as if it were sliding on ice. Instead, I’ll give it a little bit of friction.
I created a physics material for the ramp. It’s values are as follows:
I also created a physics material for the container that falls:
This set up allows us to really tweak and adjust the values, not only on the physics material, but the rigidbody as well! You can get pretty in-depth with this stuff and make some really convincing phyics simulations.