Thursday, February 8, 2018

Top Down Stealth Toolkit Basics: Patrol Movement Systems

The patrol movement systems for Guard AI in Top Down Stealth Toolkit is driven through a modular component-driven design that ensures minimal coupling between the associated feature & the parent entities that use them. This essentially means that you can easily reuse the functionality wherever required without having to worry about getting bogged down in deep inheritance cycles or having to copy paste large chunks of code between classes that are otherwise not related by a parent-child relationship.

The 'BPC_PatrolMovementControl' component attached to the Patrol Guard AI parent class supports three different types of patrol modes: Stationary, Fixed Waypoints, & Random Waypoints. These can be set for each individual patrol guard from the editor through the publicly editable variable 'PatrolMovementControl' as shown below:

Here is a brief overview of the three patrol modes:

Stationary: The Stationary mode setting is used when AI bots need to be assigned to guard a specified location without any actual patrol movement. This does not impact their decision-making process when it comes to responding to stimuli & hence they can move out to investigate any perceived suspicious activities in their vicinity. However, in the event that these guards fail to find the player after doing so, they will always return to their original guard location.

Fixed Waypoints: The Fixed Waypoints system enables the creation of well-defined paths for patrol movement. This is accomplished through the use of custom waypoint actors as well as an array to store references to these waypoints in a fixed order.

To create a patrol path using this system, drag & drop a set of 'BP_WaypointNode' actors into the level. They will serve as the path points that will be assigned to the AI bot. Now select the required Patrol Guard, & add a few elements (at most as many as available waypoints) to the 'FixedWaypointsArray' in 'BPC_PatrolMovementControl' component. To assign these waypoints, select the individual elements of the array & set the waypoint actors from the drop-down menu in their order of traversal along the required path (check screenshot below).

Guards that were interrupted from their path due to an external stimulus will always return to their designated path once they've completed the investigations.

Random Waypoints: Agents assigned to this mode will keep patrolling between randomly selected destinations within the level. The 'RandomWaypointRadius' parameter within the 'BPC_PatrolMovementControl' component can be used to control the search radius for acquiring new waypoints.

Using these three patrol modes, the AI entities in a level can be assigned different idle behaviors based on the roles they fulfill within the game's theme as well as the area/object they're guarding within the physical game space.