Game Development Reference
In-Depth Information
15. Then, when that NPC ticks through the Update() loop on its QuizNp-
cHelper script, the true param will be passed into the animator as shown
in the following code:
case(popupAction.MakeNpcDance):
{
Object[] QuizNpcHelperObjects =
Object.FindObjectsOfType(typeof(QuizNpcHelper));
foreach (Object item in
QuizNpcHelperObjects)
{
if ((item as
QuizNpcHelper).GetQuizNpcId() == r.data.
id)
{
(item as QuizNpcHelper).doSuccess =
true;
}
}
16. Inside QuizNpcHelper , declare the Animator component public. Then
drag-and-drop the Alexis child object on top of this method to set up the
reference association, as shown in the following line of code:
_animator =
this.gameObject.GetComponent<Animator>();
17. Inside the Update() loop of the QuizNpcHelper script, pass the doSuc-
cess parameter into the Mechanim FSM (if there is an animator component):
if (_animator)
{
_animator.SetBool("success",doSuccess);
}
18. Now, go through the questions 1 to 5 of popup_QuizNpcQuestion from the
Chapter7 folder and add a new action of the MakeNpcDance type. Make
sure to add the IDs 1 through 5 to the ID field of the data parameter for each
of these new actions.
Search WWH ::




Custom Search