Utility AI In UE5 : Part 5
Posted on October 22, 2026
Welcome back to the Utility AI series! In this part, we're continuing development of our NPC AI system by creating the tasks required to make our Command and Queue system work.
So far, we've built the foundations of the Utility AI system, including the NPC Brain, schedules and schedule modes. Now it's time to give the system the ability to actually do things.
We'll create a collection of reusable tasks that the NPC Brain can evaluate and execute. These include moving to a location, following an actor, playing dialogue and animations, and running other AI systems such as Behaviour Trees, State Trees and Gameplay Abilities.
STEP 1 - Add Tick Support to Tasks
Some tasks need to perform work repeatedly while they are active, rather than only when they first execute. For example, a task may need to update movement or monitor an ongoing action.
To support this, we'll add a TickTask function to NpcTaskDefinition. This uses BlueprintNativeEvent so the function can be implemented in C++ or overridden in Blueprint.
Modify NpcTaskDefinition.h
// Tick the task for repeated execution
UFUNCTION(BlueprintNativeEvent)
void TickTask(const FNpcBrainContext& Context, float DeltaTime);
void TickTask_Implementation(
const FNpcBrainContext& Context,
float DeltaTime
);Modify NpcTaskDefinition.cpp
The default implementation is empty. Individual tasks can provide their own implementation when they need to perform work each tick.
void UNpcTaskDefinition::TickTask_Implementation(
const FNpcBrainContext& Context,
float DeltaTime)
{
}Modify NpcBrainComponent.cpp
Finally, call TickTask on the active runtime task from the Brain Component's TickComponent function. This passes the current brain context and frame delta time to the task.
// Called every frame
void UNpcBrainComponent::TickComponent(
float DeltaTime,
ELevelTick TickType,
FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
if (ActiveTask.RuntimeTask)
{
ActiveTask.RuntimeTask->TickTask(
BuildBrainContext(),
DeltaTime
);
}
}Each graph below was captured using GraphCapturer. You can inspect the Blueprint implementation directly in the embedded graphs.
STEP 2 - Movement and Interaction Tasks
These tasks allow NPCs to navigate the world, follow characters and turn to face actors when interacting with them.
Move to Location
Allows an NPC to move to a specified location, providing a reusable building block for movement commands and queued activities.
Follow Actor
Allows an NPC to follow a target actor, useful for commands that require the NPC to keep up with a moving character.
Rotate to Actor
Turns the NPC towards a target actor, helping it face the correct direction during interactions and other activities.
STEP 3 - Dialogue and Animation Tasks
Movement is only part of the system. NPCs also need to communicate and play animations as they carry out their activities.
Play Dialogue
Provides a task for triggering dialogue as part of an NPC command or queued activity.
Play Montage
Allows the NPC to play an animation montage, making it possible to include animated actions within a task.
STEP 4 - Running Other AI Systems
Rather than rebuilding every behaviour inside Utility AI, we can create tasks that launch existing Unreal Engine AI systems. This lets the NPC Brain act as the decision-making layer while other systems handle specialised behaviour.
Run Behaviour Tree
Provides a task for running a Behaviour Tree as part of an NPC's selected activity.
Run State Tree
Provides a task for running a State Tree, allowing existing State Tree logic to be used by the Utility AI system.
Run Gameplay Ability
Allows a task to trigger a Gameplay Ability, integrating the Gameplay Ability System into the NPC task workflow.
Run Gameplay Effect
Provides a task for applying a Gameplay Effect when an NPC performs an activity that requires one.
STEP 5 - Utility and Debugging Tasks
These additional tasks provide useful supporting functionality while building and testing the system.
Wait
Allows an NPC to wait for a specified period, useful for activities that need a delay before continuing.
Print String
A debugging task for printing a string while testing task execution and the behaviour of the NPC Brain.
What's Next?
We've now covered the tasks that provide the building blocks for the Command and Queue system, from movement and dialogue to animation playback and integration with Unreal Engine's other AI systems.
With TickTask support in place, active tasks can also perform repeated work over time. These tasks give us the functionality needed to continue developing the system and make NPC commands more useful and flexible.
Check out the video for the full walkthrough, and stay tuned for the next part of the Utility AI series!