Setting Formations using Apex Steer and Apex Utility AI


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_11”, as well as a tutorial on how to set formations on an Apex Steer group in the Apex Utility AI.


We want the AI to make a group change between different Apex Steer formations. To start with the AI needs to know what group to set the formation on, as well as the formations that it can change between. We also store the last set formation on the Context, in order to avoid setting the same formation on the group twice in a row.


Our Scorer in this case is used to evaluate if the group has a formation or not. We need to be able to know whether we have a formation on the group or not. Because if we do, we want to clear the formation, otherwise we want to set a different random formation.


We also need to give the AI the ability to set a formation, but we do not want the AI to set a formation type that the group already has, therefore we get a random formation from the Context, and compare it to the last used formation, and we do that until we get a formation that does not match the last used one.


The AI needs to know how to clear the group’s formation. Since we are using the TransientGroup type from Apex Path, we get access to the convenient extension method ClearFormation, as seen in the code snippet below.

Apex Utility AI

The AI that we assign to the Group Controller will now have two actions it can choose between, ClearFormation and UpdateFormation. We want to clear the Formation if the group currently has a formation. We add a new Qualifier to the AI’s Selector and assign the HasFormation Scorer to the Qualifier as well as adding the ClearFormation Action to the Qualifier. If the group does not have a Formation, we want to assign one to it, thus we add the UpdateFormation to the Default Action on the Selector. We probably also want to change the Interval of the AI to e.g. five (5) seconds, because if we keep it at a low value, the Units will not have time to form the group visually.

A screenshot of a group in circle formation can be seen below.