Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Creating E-Learning Games with Unity

You're reading from  Creating E-Learning Games with Unity

Product type Book
Published in Mar 2014
Publisher
ISBN-13 9781849693424
Pages 246 pages
Edition 1st Edition
Languages
Author (1):
David Horachek David Horachek
Profile icon David Horachek

Table of Contents (17) Chapters

Creating E-Learning Games with Unity
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Introduction to E-Learning and the Three Cs of 3D Games 2. Interactive Objects and MissionMgr 3. Mission One – Find the Facts 4. Mission One – Future Proofing the Code 5. User Interfaces in Unity 6. NPCs and Associated Technology 7. Mission Two – Testing a Player's Learning 8. Adding Animations 9. Synthesis of Knowledge 10. An Extensible Game Framework Pattern in Unity Index

Building a collection of NPC conditions and responses


To specialize how the NPC will respond, we need to write specific conditions and response classes and then populate the DecisionMgr for the NPC by placing these components in the editor. To prove this, let's develop a test case for an NPC that will perform the following logic:

  1. Patrol on a curve, facing forward.

  2. When the NPC gets close enough to the player, stop and face the player.

  3. When the NPC is far enough away from the player, follow the path and face forward.

To implement this logic, we will need two conditions and one response.

Implementing the condition_closerThanThresh script

Let's create a condition to check if the NPC is close enough to the player. This will be used by the npcDecisionMgr to determine when to stop patrolling and face the player.

  1. Create a new script called condition_closerThanthresh.

  2. In MonoDevelop, edit the signature of the class declaration so that it inherits from npcCondition rather than MonoBehaviour. Also, add the...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}