ENEMY AI
Enemies are full gameplay citizens, not scripted props: they're spawned at runtime through the same initialization pipeline as players, perceive the world through sight, sound, and damage, fight through the Gameplay Ability System, and garbage collected and cleaned up correctly in a multiplayer, multi-world environment.
01 | Spawning
Enemy Spawn Manager
A spawn manager component, added to the GameState by each map's Experience definition, owns the enemy population. It tracks every live bot, spawns reinforcements, and gives each map its own spawn rules without touching game code.
Runtime-spawned enemies run the same player initialization pipeline as human players, so team assignment, perception affiliation, and team-based visuals (like grenade indicators) work identically for bots and NPC's.
The spawn manager is also the encounter's broadcaster: it binds to encounter combat state changes and publishes a verb message GameplayTag through the GameplayMessage subsystem whenever combat starts or ends. Any system can subscribe without coupling to the AI — the music system currently listens and drives its Quartz combat states from it.
02 | Encounters
Data-Driven Wave System
Encounters are authored, not coded. An EnemySpawnTrigger volume placed in the level fires an EnemySpawnDefinition — a data asset that describes the entire fight — so a designer builds an encounter by dropping a trigger, editing data, and never touching C++.
The definition is an ordered list of Waves. Each wave holds Entries — an Enemy Pawn Data (e.g. PD_Enemy_Police, PD_Enemy_Soldier), a Count, and a Spawn Location Tag — plus a Delay Before Wave, a Trigger Delay, and an overall Wave Completion Mode that decides when one wave hands off to the next. Spawning enemies through Pawn Data is the same path the hero uses, which is exactly why bots run the full player-initialization pipeline.
Placement is decoupled by GameplayTag: EnemySpawnLocation actors are positioned and tagged around the level (e.g. Enemy.SpawnLocation.MilitaryBase.Scaffold), and a wave entry references a location by tag rather than a hard actor link. Locations can be easily moved, added, or reused without ever editing the spawn definition.
The definition also reserves Patrol Entries for an in-progress EnemyPatrolComponent, which will give enemies patrol routes between waves and report back into wave progression. This turns static spawns into a living encounter.
03 | Perception
Sight & Hearing
Enemies use AI Perception with sight, hearing, and damage senses, filtered by team affiliation so they react to hostiles and ignore allies.
Gunfire noise is reported from the server-side Weapon Fire Ability rather than from audio effects. This is a subtle but critical multiplayer detail. GameplayCues only run on the clients that hear them, so reporting noise from the authoritative fire path is what lets server-side AI hear every player's shots, not just the host's.
04 | Behavior
Behavior Trees
Enemy decision-making runs on Behavior Trees, driven by perception stimuli and blackboard state for engaging, chasing, and losing the player. Since the enemy class uses their own light-weight Enemy Component rather than the Hero Component for movement, Gait (Walk, Run, Sprint) is directly controlled by each Sequence as a Service for animation smoothing and replication.
05 | Locomotion
Animation-Driven Movement
Enemies share the player's motion-matching animation pipeline (Epic's Game Animation Sample), which assumes player input intent that AI doesn't have. To bridge that, the enemy character derives its gait from actual velocity instead of input state — so the animation chooser blends smoothly through walk and run while the behavior tree ramps movement speed, with no stutter or snapping.
06 | Lifecycle
Death & Cleanup
Enemy teardown is fully ordered: on death, the AI's brain is shut down before its controller is destroyed, preventing orphaned controllers from accumulating during play or leaking into the next world after travel. The spawn manager's bot tracking stays accurate across the entire session.
In Development
RCEnemyPatrolComponent — patrol routes & wave hand-off
Expanded Behavior Trees & StateTree integration
Primary melee & weapon holstering abilities
Melee combat animations & anim layers