RAIN AI
RAIN has this section put together pretty well. In reality, we only have one small section 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, navigate 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 screenshot:
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 a path. However, what if we want to have a character patrol an area by walking around back and forth to different points without always following the same route...