Using Apex Utility AI to Prioritize Enemies with Apex Path

Introduction

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

The purpose of this document is to provide a description to the classes used in the scene “AI_Demo_6”, as well as a tutorial on how to create a simple Apex Utility AI that targets one of three enemies based on time using Apex Path.

Setting up the Scene

We set up the scene just as we did in AI Demo 5. We need a Game World and a Unit with the NavigatingUnit Quick Start components, applying the same considerations as in AI Demo 5. However, this time we also need to give the Unit the SteerToLookAt Component to ensure the unit uses the lookAt property on the UnitFacade class.

Difference with Apex Path

We want to use Apex Path to make the Unit rotate towards different targets. Before, in AI Demo 2, we rotated using Unity’s LookAt method on the Unit’s Transform. Unfortunately, this is an instantly applied rotation, lacking any smoothing. If we use Apex Path to do the rotation we can get a smooth rotation. The code implementation is not very different from how we previously did in AI Demo 2.

We can compare the differences for each class:

  • Context: Instead of having the Transform Property, we now have the UnitFacade Property.
  • Action: Since we removed the Transform Property we cannot call Unity’s “LookAt” method through our ActionWithOptions-deriving action. Instead we set the “lookAt” field on the UnitFacade to be equal to the position we want to look at. This can be seen in the below code snippet. Since we added the “Steer To Look At” Component to the Unit, it now knows how to use that field in order to rotate.