Game Development Reference
In-Depth Information
Now that we have added our new tracking systems to the game, let's create some
objects to interact with:
1. Create a sphere and place it on the ground plane. Name it
A_Coin
and dis-
able the mesh renderer component. On the sphere collider, click the
IsTrig-
ger
checkbox so that we can detect when the player enters the object.
2. Add a
Rigidbody
component to the object. This is necessary for the
OnTriggerEnter
callback to be dispatched by the engine. Remember, the
way Unity detects when the player (or any other object) enters a trigger is
by checking its
Rigidbody
component; so, if there is no such component at-
tached, the the callback will not be dispatched.
3. Add a
CustomGameObject
script to this object. Set the display name to
money
and the object type to
coin
.
4. Add a
MissionToken
script to this object. Set
id
to
1
,
Title
to
token
, and
the
Description
to
mission 1 token
.
5. Add an
InteractiveObj
script to this object. Set
Rot Axis
to (
0
,
1
,
0
) to
make the object rotate horizontally about the
y
axis. Set
Rot Speed
to
40
for
a gentle rotation.
6. Add an
ObjectInteraction
script to this object. Set the interaction to
putInInventory
. Set the interaction type to
accumulate
. Point
Tex
to
the
Coin-icon
coin texture.