Book Image

Creating E-Learning Games with Unity

By : David Horachek
Book Image

Creating E-Learning Games with Unity

By: David Horachek

Overview of this book

Table of Contents (17 chapters)
Creating E-Learning Games with Unity
About the Author
About the Reviewers

Putting it all together

Let's test our DecisionMgr class by integrating these custom conditions and responses into an NPC instance.

  1. Find the NPC instance from earlier, and select the npcScript class.

  2. Note that the DecisonMgr reference is embedded in the class (instead of waiting for a reference to the GameObject). Click on the triangle, and notice that you can see the public interactions list that this class contains. By setting the size member variable, we can design and tailor the interactions for this NPC's DecisionMgr to perfectly match our gameplay needs.

  3. Click on the size field of the interactions list, and set it to 2. We will have two interactions on this NPC.

  4. Click on the Element 0 field. Make sure its active checkbox is set to true; this ensures that this interaction is always evaluated. Note that the Condition and Response fields are waiting for a reference to be set.

  5. Drag-and-drop an instance of condition_closerthanThresh, and add it to the NPC.

  6. Set the thresh to 15 units, the trackObj...