Controller

This page aims to explain the technical details of the Enemy AI Controller. Here, you will find tables showing the available properties and functions for this component.


Overview

The Enemy AI Controller is the central unit that drives enemy behaviour. It is responsible for launching the behaviour tree, managing blackboard values, and coordinating the interaction between perception, combat, movement, and health components. By reading the assigned Enemy Config, the controller determines the initial state of the enemy (patrolling, roaming, or idle) and sets up the behaviour tree accordingly.

In addition, the AI Controller acts as the bridge between the AI and the environment. It listens for perception events such as spotting or losing sight of a target, updates blackboard keys to reflect the new state, and ensures that the behaviour tree transitions smoothly between tasks like patrolling, chasing, and attacking. This makes the controller the backbone of the entire AI system, ensuring consistent decision-making and synchronisation across all enemy features.

Properties

The Enemy AI Controller provides a set of properties that are essential for managing the AI’s behaviour and interaction with the game world. The following table lists all available properties along with a short description of their purpose.

Name
Type
Description

Debug

Boolean

Enables or disables debug mode for the AI controller.

Show Screen Message

Boolean

If enabled, debug information is shown directly on the screen.

Show Log Message

Boolean

If enabled, debug output is written to the log for easier troubleshooting.

AI Perception System

Component

The AI Perception component responsible for handling sight, sound and custom senses.

Visual Perception Timer

Timer Handle

Used to manage periodic checks for visual perception updates.

Running

Boolean

Tracks whether the AI controller is currently active and running behaviour logic.

Config

BP Enemy Config

Reference to the enemy’s configuration asset, defining behaviour and attacks.

Patrol Route

BP Patrol Route

Reference to the assigned patrol route, defining waypoints for patrolling.

Origin

Vector 3

Stores the original spawn or reference location of the enemy.

Last Target

Actor

Holds a reference to the most recently perceived target (e.g. player).

Controlled Enemy Character

BP Enemy Character

Reference to the pawn/character currently controlled by this AI controller.

Functions, Macros & Events

The Functions, Macros & Events of the Enemy AI Controller form the core logic of the system. They define how perception, movement, combat, and internal states are processed. Functions are used to execute specific tasks, while Events act as entry points for external influences (such as perception updates or health state changes). Macros, on the other hand, provide quick access to commonly used data like configuration or perception types.

Below you will find an overview of all available functions, events, and macros implemented in the controller.

Functions

The Enemy AI Controller includes a variety of functions that define its runtime behavior. These functions cover core aspects such as debugging, state management, perception processing, and system setup. Each function is categorized to give you a clear overview of its purpose and how it integrates into the AI logic.

Name
Category
Description

Print Debug Message

Debugging

Outputs debug text to screen or log (depending on settings).

Set Patrolling

Modes

Allows to set the AI to patrol during runtime.

Set Mode

Modes

Sets the AI to a specific behaviour mode (Patrolling, Roaming, Idle, etc.).

Process Visual Perception

Perception

Handles visual stimuli and updates blackboard values accordingly.

Process Sound Perception

Perception

Handles auditory stimuli and updates blackboard values accordingly.

Visual Perception Timer

Timers

Timer function for refreshing or checking visual perception state.

Toggle AI Behavior

Timers

Enables or disables the AI behaviour tree.

Toggle Crowd Avoidance

Timers

Enables or disables avoidance logic in crowded scenarios.

Setup Blackboard

Timers

Initializes and configures the blackboard for behaviour tree use.

Get Controller Config

Timers

Returns the assigned config asset from the controller.

Get Origin Location

Timers

Returns the AI’s initial/origin position, often used for resets.


Graphs (Events)

The Enemy AI Controller defines several event graphs that handle important runtime logic. These events are triggered by changes in possession, perception updates, or health state changes, ensuring the AI stays reactive and synchronized with the game environment.

Name
Category
Description

Event On Possess

Possession Logic

Triggered when the AI Controller possesses a pawn. Initializes logic.

Event On UnPossess

Possession Logic

Triggered when the AI Controller unpossesses a pawn. Cleans up logic.

On Target Perception Updated

Perception Logic

Fired when the AI perception system detects or loses a target. Starts perception processing.

On Other Perception

Perception Logic

Event for handling non-standard senses (e.g., smell, magic).

Connect Health System

Health System

Links the AI controller to the pawn’s health component. Binds to needed health events such as when the health state changes.

On Health State Changed

Health System

Called whenever the pawn’s health state changes (e.g., Dead, Alive). Starts the ragdoll and terminates AI logic.


Interfaces

The Enemy AI Controller implements several interfaces that allow external systems and components to interact with the AI. These interfaces provide methods for initialization or data requests, making the AI flexible and easy to integrate into different gameplay scenarios.

Name
Category
Description

Request Patrol Route

Getter

Returns the assigned patrol route asset.

Request Config Asset

Getter

Returns the assigned config asset.


Macros

The Enemy AI Controller includes several macros that simplify common tasks and reduce repetitive logic. These macros provide quick access to frequently used components and configuration values, making the AI easier to maintain and extend.

Name
Description

Get Movement Component

Returns the controlled pawn’s movement component.

Get Pawn Config

Retrieves the configuration asset assigned to the pawn.

Get Pawn Patrol Route

Retrieves the patrol route assigned to the pawn.

Get Perception Type

Checks which type of perception triggered (Visual, Sound, Other).

Last updated