Game Development Reference
In-Depth Information
This script handles the two types of possible collisions by handling OnCollisionEnter and
OnTriggerEnter messages. Consequently, it sends Collect message to the colliding object
and provides itself as the owner. This results in a generic collecting script that can collect any
object as long as it handles Collect message, and not only keys. Before carrying on, it is a
good idea to revise the list of scripts we need: we will use a PhysicsCharacter with FPSIn-
put . These two scripts should be attached to capsule that represents the character and has
the camera added as a child. In order to collect collectables, we need both InventoryBox and
CollisionCollector scripts. Now we have to make an object that resembles the key we need to
collect, and add the CollectableKey script to it. For example, you can make a simple key shape
like in Illustration 79.
Illustration 79: A simple key shape to be used as collectable key object
Search WWH ::




Custom Search