Part 08 - Physics.

By Jamie Chatterton / 2018-06-12

There are a few things required for physics.

Colliders and RigidBodies

Colliders define the collision shape of an object. It is these that the Unity physics engine will use when it needs to work out if two objects have actually hit each other.

The ProBuilder tools will add the "Components" required for the 'Colliders' but it won't add the RigidBody.

A RigidBody is the part which actually does the physics simulation. Unless there is a RigidBody component on a GameObject it will just remain static. Objects can collide with it, but it won't react.

To make the 'coin' fall onto the 'floor' it needs a RigidBody adding to it.

Select the 'Cylinder'

Rename it "coin" … so we don't get confused in these instructions… in the "Inspector" at the top, rename it "coin".

At the Bottom of the Inspector, select "Add Component"

Open this image in a new tabAdding a component
Adding a component

Start typing "Rigidbody" and select the "Rigidbody" component when it becomes obvious.

You will now have the Rigidbody component added

Open this image in a new tabFinding the Rigidbody component
Finding the Rigidbody component
Open this image in a new tabRigidbody added to scene
Rigidbody added to scene

There's a few things to fix in the latest version of Unity that don't work out-of-the-box.

In the Inspector view above. In the "Mesh Collider" make sure that "Convex is ticked". This is telling Unity that the "Mesh", the collection of points and faces that make up the model, are, well, convex, they don't have angles over 180 degrees. It helps with the physics calculations.

For the coin object, right at the top, make sure "Static" is unticked. Again, this is an optimisation thing. Telling Unity the object is static in this way allows it to precalculate things, like lighting and physics. But we want the coin to move, so Unity will have to calculate these things on-the-fly.

Go to the floor object and untick "static". Same reasons applies to the floor.

Click play. The coin should drop onto the floor object.


Git repository:

More posts in this series.