Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Creating E-Learning Games with Unity
  • Table Of Contents Toc
Creating E-Learning Games with Unity

Creating E-Learning Games with Unity

By : David Horachek
4.4 (10)
close
close
Creating E-Learning Games with Unity

Creating E-Learning Games with Unity

4.4 (10)
By: David Horachek

Overview of this book

Table of Contents (17 chapters)
close
close
Creating E-Learning Games with Unity
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1
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...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Creating E-Learning Games with Unity
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon