Rapid Unity Tutorials #1: Physics Materials
In a recent Unity3D prototype I created I needed to have a number of different physical objects within the same scene; ice, metal, dirt and marble.
Now it had been a few years since I last did anything with physics materials in Unity (my previous prototypes didn’t require any) so I was a bit rusty. After playing around with it for a day or two I decided to make myself a quick how-to and a cheatsheet for materials to be used in the future, and I thought I’d share that with y’all.
Setup
Creating Physics Materials
- Create a new Physic Material in the “Project Assets” window by right-clicking and selecting “Create -> Physic Material”
- Give it a name like “MetalMaterial” and click to open the “Inspector”
Physic Material Inspector
The inspector have 5 different things for us to consider:
A brief explanation of each:
- Dynamic Friction (0–1): How much friction applied to the object when in motion. The higher the friction the more outside force (like gravity or an explosion) impacts it; 0 is ice, 1 is super-glue sticky.
- Static Friction (0–1): How much force is needed to get the object moving in the first place basically; 0 means anything gets it going, 1 means it require a heavy amount of push
- Bounciness (0–1): How bouncy the surface is when something collides with it (or it collides with something); 0 is your surface made of mud, 1 it is made of rubber.
- Friction / Bounce Combine (Average, Minimum, Multiply, Maximum): This tells Unity which physics material takes priority when making the calculation. Defaults to “average” where it tries to work out a middle ground, but sometimes it is useful to use minimum (where the lowest value of the two objects colliding is used) or maximum (where the highest value is used), e.g. when a rubber ball hits a pile of mud, you don’t want to bouncing away, so use “Minimum”.
More details at: Official Documentation
Now that we got an idea how to use them and what the difference values work, let me share with you some quick materials I have set up. These are approximations, but I did have a look at other game engines to get the numbers for these and managed to find the old build-in Unity ones (which do not seem to be included anymore?)
Cheatsheet
Rubber Material
- Dynamic: 0.8
- Static: 0.9
- Bounciness: 0.8
- Friction Combine: Maximum
- Bounce Combine: Average
Ice Material
- Dynamic: 0.05
- Static: 0.1
- Bounciness: 0.05
- Friction Combine: Multiply
- Bounce Combine: Multiply
Wood Material
- Dynamic: 0.475
- Static: 0.475
- Bounciness: 0
- Friction Combine: Average
- Bounce Combine: Average
Metal Material
- Dynamic: 0.15
- Static: 0.2
- Bounciness: 0
- Friction Combine: Minimum
- Bounce Combine: Average
Mud Material
- Dynamic: 1
- Static: 0.9
- Bounciness: 0
- Friction Combine: Minimum
- Bounce Combine: Minimum
Demo
Lastly, another quick demo on a slanted surface:
That’s it for this Rapid Unity Tutorial! We have many more things to share in the upcoming posts; more tutorials and development details from our games. Let us know if you liked this one or have recommendations for improvements in the comments! :)