Game Development Reference
In-Depth Information
public GameObject RaceStarterObj;
This script works largely in the same way as SetupMissionOne , with some
subtle changes due to the different design needs. As five random quiz cards
are selected (rather than flags), we instantiate QuizNpc to stand that loca-
tion:
GameObject QuizNpcInstance =
(GameObject)Instantiate(QuizNpc, QuizPos,
new Quaternion(0,0,0,1));
7. As we loop over the selected questions, we hand off the correct answer pop
up for each NPC question to the QuizNpc class itself. The NPC will then
hand this off when the quiz question is actually activated (when player is
close enough to NPC). The NPC stores the reference to the correct answer
pop up through a QuizNpcHelper script attached to it as shown in the fol-
lowing code snippet:
QuizNpcIstance.GetComponent<QuizNpcHelper>().SetPrefabReference(
CorrectPopups[k]);
QuizNpcInstance.SetActive(true);
8. We install the QuizCard itself into NPC's ObjectInteraction inside the
Prefab member variable of the setupLevel2 class. This allows interact-
iveObject to display the QuizCard when the player is close enough as
shown in the following code snippet:
ObjectInteraction oo =
QuizNpc.GetComponent<objectInteraction>();
if (oo)
oo.prefab = quizPrefab;
9. Then we add MissionToken from the current chosen pop up and add it to
missionTokens of the mission for this level. This way, the mission can track
the randomly chosen quiz questions from this method as shown in the follow-
ing code snippet:
Search WWH ::




Custom Search