Part 08 - Physics.
There are a few things required for physics.
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 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"
Start typing "Rigidbody" and select the "Rigidbody" component when it becomes obvious.
You will now have the Rigidbody component added
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.
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
More posts in this series.
- Part 01 - Installation
- Part 02 - Concepts
- Part 03 - Navigation
- Part 04 - Git and Unity
- Part 05 - Building a project
- Part 06 - Adding some plugins
- Part 10 - Pushing coins
- Part 11 - Custom Scripting
- Part 12 - Spawning Things
- Part 13 - It is still too fast
- Part 14 - Coins are piling up
- Part 15 - Materials
- Part 16 - User Control
- Part 17 - Keyboard input - Fire
- Part 18 - Keyboard input - Movement
- Part 19 - Deleting Coins
- Part 20 - Walls
- Part 21 - Adding a GUI
- Part 22 - Adding the GameController
- Part 23 - Scoring Links with Events
- Part 24 - Refining the Game - Part 1
- Part 25 - Refining the Game - Part 2
- Part 26 - Refining the Game - Part 3
- Part 27 - More Refinements
- Part 28 - Slowing the user down
- Part 29 - Some more changes