O'Reilly logo

Creating E-Learning Games with Unity by David Horachek

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing the NPC decision system

The NPCs in our e-learning game will need to be able to interact with the player and the world in addition to following a user-defined path. While the path-following code was easily encapsulated in one file, we will see that a general purpose solution to the first problem requires a more intricate design.

Our solution will be modeled around and function similarly to a question-and-answer system. A number of classes will be required for implementation:

  • npcCondition: This is the base class for a question that the NPCs logic will ask about the player or the world.
  • npcResponse: This is the base class for a response that the NPCs logic will invoke if a condition is found to be true.
  • npcInteraction: This container class ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required