Physics
In Unity, physics simulation primarily focuses on the use of the Rigidbody component. When the Rigidbody component is attached to any object, it will be taken over by the physics engine. The object will fall with gravity and bump into any object that has a collider. In our scripts, making use of the OnCollision
function and the OnTrigger
function requires a Rigidbody component to be attached to at least one of the two interacting objects. However, a Rigidbody component can interfere with any specific movement we might cause the object to take. Every Rigidbody, though, can be marked as kinematic, meaning the physics engine will not move it. The CharacterController component that we used for our tank is a special, modified Rigidbody. In this chapter, we will be making heavy use of the Rigidbody component to tie all of our birds, blocks, and pigs into the physics engine.
Building blocks
For our first physics objects, we will create the blocks that the pig castles are built out of. We...