Game Development Reference
In-Depth Information
Creating the setupLevel2 Prefab
The setupLevel2 Prefab will be activated when the user presses the start button on
popup_Level2Start . It will finish the initialization of the mission for the level in the
missionMgr script. Let's perform the following steps to create the setupLevel2 Pre-
fab:
1. Create a new Prefab named setupLevel2 . Duplicate the SetupMissionOne
script from mission one, and rename the duplicate SetupMissionTwo . Add
an instance to setupLevel2 .
2. Inside MonoDevelop, change the class declaration to SetupMissionTwo as
shown in the following line of code:
public class SetupMissionTwo :
MonoBehavior {
3. We will use the same pattern for choosing random QuizNpc locators as we
did for the flag locators in mission one. In addition to the QuizNpc Prefabs
and the spawnPoints lists, add a list of CorrectPopups to the class.
4. This class will hold the pop ups that are shown to the user when a correct an-
swer is given for a particular quiz question. This will be populated by the user
in the editor, and it will hold a number of unique pop ups, which will give the
user a mission token when clicked through. We will store these unique pop
ups in a list, as declared in the following line of code:
public List<GameObject> CorrectPopups
5. Add a public reference to QuizNpc Prefab. This is the model (and eventually
animations) for the QuizNpc class on the path giving the questions. Once the
locations are randomly chosen, instances of this model will be placed around
the track. This can be done with the following line of code:
public GameObject QuizNpc;
6. We will also keep a reference to the raceStarterObj so that we can enable
it when the setupLevel2 class is enabled. This will have the effect of start-
ing the racers' movement. This can be done with the following line of code:
Search WWH ::




Custom Search