Game Development Reference
In-Depth Information
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 . Underneath it, add more empty GameObjects. Give them all a tag, Np-
cActivityTarget , which you might need to create. Distribute these targets to dif-
ferent locations on the screen like this:
The preceding screenshot shows how our basic React scene setup with targets
should look like.
Search WWH ::




Custom Search