Game Development Reference
In-Depth Information
RAIN AI
RAIN has this section put together pretty well. In reality, we only have one small sec-
tion to change from the pathfinding demo, especially because the pathfinding demo
had actually turned off the patrol feature.
Start with the project for RAIN AI from
Chapter 1
,
Pathfinding
. From the menu, nav-
igate to
RAIN
|
Behavior Tree Editor
. From the editor, select
FollowGreenRoad
.
Under
Sequence
is a patrol route node called
waypointpatrol
; select it. Finally, we
have a property called
Loop Type
. Presently, it is on
One Way
, which stops at the last
waypoint. You can switch it to
Ping Pong
or
Loop
, as shown in the following screen-
shot:
Ping Pong
bounces you back and forth on the path, while
Loop
connects the last
waypoint to the first to start over.
This works when creating a typical patrolling behavior, where a character loops along
apath.However,whatifwewanttohaveacharacterpatrolanareabywalkingaround
back and forth to different points without always following the same route? In RAIN AI,
we can do this by using a waypoint network instead of a waypoint graph and updating
our behavior tree to randomly pick different points in the level to go to.
To illustrate this, create a new scene, and like in our current patrol example, add a
character and some blocks and create a navigation mesh. Separate the blocks a bit