Adding the Enemy AI

Let's go back to Unreal Engine and focus on Content Browser. We now need an opponent. To add this, follow these steps:

  1. Right-click and select Blueprint.
  2. At the lower end of the window, let's drop all the classes and search for AIController.
  3. Select AIController under Controller and hit Select in the lower-right corner.
  4. We will name this AIController Enemy.
  5. Open Enemy AIController and go to the EventGraph section.

First, we must find Hero and then store it in a local variable to be used at any time. To do so, follow these steps:

  1. Right-click in an empty area within EventGraph and search for Event Begin Play.
  2. Pull from the exec pin and search for Get All Actors Of Class.
  3. Set the Actor Class pin to Hero.
  4. Pull from the Out Actors array and ...

Get Unreal Engine 4 AI Programming Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.