Moving Units to Random Destinations using Apex Utility AI and Apex Steer

Introduction

This document is a part of a series of tutorial documents for getting started with the Apex Utility AI using Apex Path and Apex Steer.

The purpose of this document is to provide a description to the classes used in the scene “AI_Demo_10”, as well as a tutorial on how to create an Apex Utility AI that moves an Apex Steer group to random positions.

Context

We want the Units to move in random directions, starting from when the entire group of Units is standing still. To be able to know when that is, the AI needs to know about every member of the group. We make use of a TransientGroup property to be able to easily add members and make them all move with one simple method call. Thus, the context class looks as shown in the example code snippet below.

Scorer and Action

In the scorer we need to check whether the group is moving or not and in the Action we need to move every member of the group. Conveniently, TransientGroup has the velocity field and the MoveTo method that we can use instead of having to loop through all members in the group. The resulting utility AI setup can be seen in the below screenshot.

Behaviour

We need to provide an AI to the Group Controller instead of all the Units. However, the units should still have the same components as the ones we used in AI Demo 9. They can be added through the VectorFieldNavigation Quick Start. When the Group Controller tells the group to move, a vector field will be generated, which we can see in the image below. This makes every member of the group move towards the destination using the Apex Steer-provided default vector field implementation.