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)

RAIN AI


We have already looked at a basic wander behavior for RAIN in Chapter 2, Patrolling, when creating patrolling AI, but there, we manually created each possible location for the NPC to go to. In this demo, we will pick random points to wander to from anywhere in the navigation mesh. The NPCs won't have any interaction, though such features are not difficult to add. Here is a breakdown of the steps we will do in this section:

  • Set up a world

  • Build the behavior tree

  • Add a script to pick new points

  • Add the NPCs

  • Learn about the RAIN AI world and behavior tree setup

First, we'll create a new world. Start with a large plane called floor, and add some cubes shaped into walls. You will need to add a navigation mesh and bake it into the scene. These are the same steps we have performed for RAIN demos in earlier chapters. The following is an example of how the scene could look:

Next comes the behavior tree. From the RAIN menu, select Behavior Tree Editor. Create a new tree called RandomWalk. The objective...