Game Development Reference
In-Depth Information
4. Add an InteractiveObj script to this object. Set the rotAxis to ( 0,1,0 ) to
make the object rotate horizontally about the y axis. Set the rot Speed to 40
for a gentle rotation.
5. Add an object interaction script to this object. Set the interaction to
putInInventory . Set the interaction type to Unique . Point the text to the
Alabama state flag texture.
6. Drag-and-drop this GameObject into the OnCloseEnough variable of the
InteractiveObject component. This will connect this reference to the
ObjectInteraction component on the GameObject itself.
7. Add an external force of ( 1.7 , 0 , 0 ) and a random force of ( 2 , 2 , 2 ) to the
interactive cloth to make the flag flap in the breeze. Consider experiment-
ing with the external force and random force properties of the Interact-
iveCloth script to explore the various different flag behaviors that can be
achieved.
We now have a Prefab that we can customize for each state flag. Note the nice anim-
ation on the flag when the player walks by it. Let's create 50 Prefabs by applying the
correct texture to the interactive cloth component and then dragging the hierarchy
into the project tab. Let's also add the following script instances to each Prefab.
1. CustomGameObject : Set the object type to flag , name it according to the
state, and add a reference to the info card for this flag; the info card will show
up when the inventory is clicked on, telling the user about the flag, the state
name, and some trivia.
2. Add an InteractiveObj script, leaving everything as zero except for the
reference to ObjectInteraction (also an instance on the flag Prefab).
3. Add an ObjectInteraction script to this object, and connect the referen-
ce to the InteractiveObj script. Set its parameters to PutInInventory
and Unique , and set the texture to the state flag texture; the text will be the
icon that shows up in the inventory when this item is collected.
4. Add a MissionToken script. Name the token the same as the state, and
give each flag a unique ID ranging from 0 to 50.
Congratulations! Once you have done this 50 times (it may take a while), you will
have 50 state flag Prefabs. These should then be added to the flagPrefabs list in
the SetupMissionOne script.
Search WWH ::




Custom Search