Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Unity AI Programming Essentials

You're reading from  Unity AI Programming Essentials

Product type Book
Published in Dec 2014
Publisher
ISBN-13 9781783553556
Pages 162 pages
Edition 1st Edition
Languages
Author (1):
Curtis Bennett Curtis Bennett
Profile icon Curtis Bennett

React AI


React AI doesn't come equipped with a patrol script, so we provided one. We'll start with this behavior tree script and look at how it works and how to use it. Here are the steps to reproduce it:

  1. Create a patrol script.

  2. Create a patrol AI.

  3. Set up the NPC patrol.

To start with, we've provided a script for you to use. In it, I started with the last script for pathfinding, and then I extended it to use a similar configuration to the patrol path in Quick Path's patrol script. Here are a couple of key points about this script:

  • It is based on the FollowThePlayer script from the previous chapter.

  • You can find the code in the book's contents at \Scripts\React AI\Patrol.cs.

  • It stores a public array of Vector3, so the Inspector UI can allow designers to set the waypoints.

  • Instead of the target being a player, it is set to the next waypoint in the list. Once we are close enough, it selects the next waypoint. Close Enough is the float field that allows the inspector to find it.

  • If there are no waypoints...

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}