Game Development Reference
In-Depth Information
Creating the FoundAllTheFlags Prefab
The
FoundAllTheFlags
Prefab can be created by performing the following steps:
1. Create a new
GUITexture
object, and name it
returnFlagsToMonument
.
2. Drag-and-drop an instance of the
returnFlagsToMonument
Prefab to this
object.
3. Create a new
Cube
GameObject, and name it
FlagReturnTriggerObj
.
This object will be an invisible
InteractiveObj
class that will (on being
picked up by the user), add the final token to the inventory, which will satisfy
the second mission in the level.
4. Scale and position it so that it rests on top of the monument. Give it a large
height, and make it about 15 percent wider and deeper than the monument
itself. Add this object to the
FoundAllTheFlags
object.
5. Disable the mesh renderer on this object so that we no longer see it.
6. Add
MissionToken
to this object, give it an ID of
10
. Give it a title
ReturnToBase
and an appropriate description, such as
Returns Flags
To Base
.
7. Add an object interaction script. Set the interaction to
AddMissionToken
,
and set the
interactionType
to
Unique
.
8. Add an
InteractiveObj
class, and set the
OnCloseEnough
script refer-
ence to the
ObjectInteractionScipt
from this object!
9. Drag this object to the project tab to create a Prefab from it.
Congratulations! Now, when this parent object (
FoundAllTheFlags
Prefab) is in-
stantiated, the following will occur:
• The
returnFlagsToMonument
Prefab will be instantiated. This object will
detach itself from the parent and display the pop-up GUITexture for a few
seconds before destroying itself.
• The
FlagReturnTriggerObj
Prefab will be instantiated. This invisible ob-
ject will sit at the top of the monument. When the user walks back to the
monument, this will result in a new mission token being collected, which will
activate the second mission and complete the level!