Performance
Documentation Unreal Engine AI Performance
What each system costs, how often it runs, and how to read stat SEC on your own hardware.
MovementEvaluatorComponentdirection sampling dominates SEC CPU time. Role assignment, action polling, awareness and reactions run on timers, on events, or only while a feature is active.
Cost Model
Every SEC system runs on a known cadence over a known loop. What that costs in milliseconds depends on your CPU, so the shape is documented here and the numbers come from your own machine through
stat SEC.The slider models linear scaling from a per-enemy figure you supply. Read one enemy's cost from
stat SEC in PIE, put it in, and the model tells you where a crowd lands.Output Log
20 enemies
1 duel50 horde150 stress
Illustrative scaling — run stat SEC in your level for real numbers
MovementEvaluator - Total
0.070 ms
MovementEvaluator - Direction Scoring
0.063 ms
MovementEvaluator - Avoidance
0.004 ms
RoleSubsystem - Role Distribution
0.001 ms
ThreatDetection - Tick
0.008 ms
Estimated SEC overhead
0.083 ms
Share of 60 fps frame budget (16.6 ms)0.50%
Low share at this count
At 60 fps you have 16.6 ms per frame. Movement direction sampling dominates the plugin's share; everything else runs on a timer, on an event, or only while a feature is active.
What Runs When
Cadence is how often the work happens. The multiplier is what makes one pass more expensive.
| System | Cadence | Work each pass | Multiplier |
|---|---|---|---|
| Movement evaluator | Every tick while EvaluateAndMove or AI Movement runs | Scores one direction per sample and picks a winner | NumSamples (default 16) |
| Avoidance | Inside the movement pass, overlap refresh at 10 Hz | Sphere overlap, then a penalty per neighbour found | Pawns packed inside the avoidance radius |
| Nav sampling | Inside the movement pass, cache refresh every NavCheckInterval (0.1 s), staggered across NavStaggerStride (4) frames | Projects sampled directions onto the navmesh | NumSamples, navmesh density |
| Detour query | On the detour recheck interval while hybrid movement runs | One path query compared against straight-line distance | Path length |
| Action scoring | EvaluationCooldown (0.1 s) on the native brain, or each Poll Action | Hard gates, then a score for every action still standing | Actions on the set, times scorers per action |
| Reaction scoring | Once per trigger rule that matches an incoming stimulus and clears its own interval, conditions and chance roll | Gates and scores the reactions that rule allows | Rules matched per stimulus, times reactions per rule |
| Awareness | Timer at EvaluationInterval (0.1 s) | Advances a meter per remembered actor and ages the rest | Actors perceived at once |
| Brain tick | Every tick, gated inside by EvaluationCooldown | Picks a phase, then drives movement and action scoring | Contains both, see the warning below |
| Role subsystem | RoleReassignmentInterval (8 s) | Fitness score per combatant per candidate role | Combatants, times roles |
| Threat detection | Every tick by default | One dot product against the focus actor | Fixed small cost |
| Melee trace | Every tick between StartTracing and StopTracing | Swept trace per socket per frame | Active trace sockets |
| Approach window | Every tick while an approach window is open | Steers the pawn toward its approach target | One pawn at a time |
| Territory | Only when something asks | Route arithmetic, or one navmesh query for a wander spot | Posts on the route |
| Combat tokens | On claim and release | Slot bookkeeping on the target | Fixed small cost |
Territory, tokens and reactions do no work until something calls them, and the brain skips its own movement pass while it is walking a leg, waiting out a post's dwell, or looking around a spot it just reached, so an idle enemy at a post costs only the brain tick.
Tuning for Scale
Details
Movement Evaluator Component (MovementEvaluatorComponent)
Movement Evaluator
Num Samples
16
Enable Avoidance
Enable Nav Aware Sampling
Nav Sampling
Nav Check Interval
0.1
Num Samples scales the direction-scoring loop. Avoidance and nav sampling both refresh at 10 Hz by default.
Num Samples: Range 4–32. Halving samples roughly halves direction-scoring work. Start at 8 for horde crowds if strafing still looks acceptable.bEnableAvoidance: Turn off when enemies never pack tightly (solo bosses, sparse open fields).bEnableNavAwareSampling: Turn off only when you accept ledge/hazard blind spots. Keeps NavCheckInterval and NavStaggerStride from doing nav probes.Hybrid movement: Distant enemies pathfind; close enemies use tactical sampling.
HybridSwitchDistance (default 800 cm) controls the handoff. See Movement System.Project-wide timers
Role and target timing live in Project Settings → Soulslike Enemy Combat → Combat Roles → Timing:
Timing
Role Reassignment Interval
8
Min Time In Role
8
Re-evaluate Targets On Reassignment
Role Reassignment Interval: How often UAICombatRoleSubsystem re-runs global assignment. Default 8 s. Set 0 to drive reassignment manually.Native brain / Poll Action:
EvaluationCooldown on USECBrainComponent or STTask_PollAction (default 0.1 s) spaces action picks. Raise it for background grunts that do not need 10 Hz decisions.Threat: Call
SetTickInterval on UThreatDetectionComponent to skip frames when you only need coarse player-look reactions.Built-in Profiling
Open the console (~) and run:
stat SEC
Registered cycle stats (from
STATGROUP_SEC):| Stat | Scope |
|---|---|
MovementEvaluator - Total | Full per-AI movement pass, containing the four below it |
MovementEvaluator - Direction Scoring | Sample loop over NumSamples |
MovementEvaluator - Avoidance | Throttled overlap scoring |
MovementEvaluator - Nav Sampling | Nav validity cache refresh |
MovementEvaluator - Detour Query | Path-length detour check |
ActionEvaluation - Scoring | Gates and scores every candidate action |
ReactionEvaluation - Scoring | Gates and scores reactions for one stimulus |
Awareness - Evaluate | One pass over remembered actors |
Brain - Tick | Native brain tick, containing action scoring and the movement pass |
RoleSubsystem - Role Distribution | Global role assignment pass |
ThreatDetection - Tick | Per-tick threat level |
Two of these are totals rather than separate costs.
MovementEvaluator - Total contains the four movement stats under it, and Brain - Tick contains ActionEvaluation - Scoring and the whole movement pass whenever the native brain drives the enemy. Adding the column up counts that work two or three times. Under a StateTree the same functions run with no enclosing brain tick, so Brain - Tick reads zero and the rest stand on their own.Melee tracing and the approach window carry no cycle stat. Measure them in Unreal Insights on
USECMeleeTraceComponent and USECApproachComponent tick.Unreal Insights: filter CPU trace events
SEC_MovementEvaluator, SEC_DirectionScoring, SEC_Avoidance, SEC_NavSampling, SEC_DetourQuery, SEC_ActionScoring, SEC_ReactionScoring, SEC_Awareness, SEC_BrainTick, SEC_RoleDistribution, SEC_ThreatDetection.For log-based diagnosis, see Debugging & Troubleshooting.
Optimizations Already in Code
- Unit-circle sample cache: trigonometry for direction samples is precomputed when
NumSampleschanges. - Throttled avoidance: overlap queries run at 10 Hz, not every frame.
- Throttled nav cache:
NavCheckIntervalplusNavStaggerStridespread nav sweeps across frames in a pack. - Timer-based roles: reassignment runs on
RoleReassignmentInterval, not per frame. - Hybrid movement: strategic pathfinding only past
HybridSwitchDistance(or while detour escalation is active). - Conditional melee tick:
USECMeleeTraceComponentstarts with tick disabled; tracing enables tick only for active swings. - Conditional action tick:
ActionEvaluationComponentticks only during action execution (hook dispatch), not while idle.
Scaling Guide
What dominates changes with the crowd, and that decides where tuning pays off.
| Scenario | Active SEC enemies | What dominates |
|---|---|---|
| Soulslike duel | 1 to 5 | Nothing worth tuning. One enemy's movement pass is noise against a frame. |
| Action RPG pack | 10 to 20 | Direction sampling, with avoidance climbing as they close on you. |
| Horde | 50 to 100 | Direction sampling across the pack. Cutting NumSamples to 8 is the largest single lever. |
| Stress test | 150+ | Direction sampling and nav probes. Raise NavStaggerStride, and slow action polling for enemies out of the fight. |
Cost scales roughly linearly with enemies running movement every frame. An enemy standing at a post, waiting out a dwell, or dead costs a fraction of one in a fight.