Game Development Reference
In-Depth Information
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
theNPCtogoto.Inthisdemo,wewillpickrandompointstowandertofromanywhere
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 of this AI is broken into three
steps, taken in this order: select a target, walk to it, and then wait a moment. This is a
good case for the RAIN decision node sequenced. Under the root node, we will right-
click and go to Create | Decisions | Sequencer .
As there is no behavior tree node built into RAIN that will choose a random location,
we will use a custom action and write our own script. Right-click on the new SEQ
Search WWH ::




Custom Search