Game Development Reference
In-Depth Information
Step 14: Create a new JavaScript and name it EndgameTriggerScript .
Open it.
Step 15: This script will be easy. When we run into this trigger, load the
level Scene-Closing:
function OnTriggerEnter (other:Collider){
Application.LoadLevel(“Scene-Closing”);
}
Why?
It's pretty straightforward here. If the player makes it to the end and runs
into the collider, the Scene-Closing scene fires.
Step 16: Save and return to Unity. Fix any syntax problems.
Step 17: Deactivate Hallway_Unbaked and activate
Hallway_Baked.
Step 18: Move the FPC_AegisChung toward the end of the map (so that
when we test in a minute, the player doesn't have to run through the
entire level).
Step 19: Add Scene-Closing to the Build Settings. Remember, to do this,
choose File>Build Settings and then drag Scene-Closing from the Project
panel into the Scenes in Build section of the Build Settings window
( Figure 17.4 ).
Step 20: Apply EndgameTriggerScript to the Trigger-Endgame trigger.
Test and play.
Step 21: When satisfied that everything works, place FPC_AegisChung
back at the beginning of the level.
Step 22: Make Trigger_Endgame a child of Hallway_BakedGroup.
Why?
Not that the character could actually get to the end of the level when the
game was all dark (the Unbaked version being visible), but just in case,
having the trigger not active until the Baked version is turned on will help
ensure the game proceeds as planned.
Step 23: Deactivate Hallway_BakedGroup and activate
Hallway_Unbaked.
Step 24: Save Scene-Hallway.
Conclusion
Great! He can win. Winning can be fun—but only when there's the possibility
that you can't. Let's create a health system so the player can lose.
Search WWH ::




Custom Search