Book Image

Unity AI Programming Essentials

By : Curtis Bennett
Book Image

Unity AI Programming Essentials

By: Curtis Bennett

Overview of this book

Table of Contents (19 chapters)

React AI


For this demo, we will duplicate the path-following behavior demo in React from Chapter 1, Pathfinding, and then update it to see some emergent behavior develop from it. We will need to complete the following:

  • Create a world with some walls

  • Create target markers in the scene

  • Create a script with a custom editor to find the targets

  • Create the behavior

  • Create NPCs and assign the behavior

Setting up a scene with React

To start out with, we will need a basic environment for characters to walk in. Create a plane, call it Floor, and add some cubes, shaping them into walls. These will need to be static so that Unity's navigation mesh can find them. Then, we'll need to select the floor and add the navigation mesh. If you've forgotten how to do any of this, it is all covered in the React tutorial in Chapter 1, Pathfinding.

Next, we need some targets. We'll use a different approach for this from our previous demos and let GameObjects mark the targets. Create an empty GameObject and call it Targets...