Performance

Documentation Unreal Engine AI Performance

Cost model, profiling with stat SEC, and tuning knobs for large enemy counts.


MovementEvaluatorComponent direction sampling dominates SEC CPU time. Role assignment, action polling, awareness, and avoidance run on timers or only while a feature is active.

Cost Model

The slider below shows linear scaling from illustrative per-enemy costs (~0.0035 ms movement, ~0.0004 ms threat). It is a planning aid, not a profile of your map. Run stat SEC in PIE to read real numbers on your hardware.
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. Even at 150 active SEC enemies, this model lands near 4% of frame budget for the plugin slice alone (animation, rendering, and game logic sit on top).

What Runs When

SystemCadenceCost driver
Movement evaluatorEvery tick while EvaluateAndMove / AI Movement runsNumSamples direction loop (default 16)
AvoidanceOverlap refresh at 10 Hz (0.1 s)bEnableAvoidance, radius
Nav samplingCache refresh at NavCheckInterval (default 0.1 s), staggered by NavStaggerStridebEnableNavAwareSampling, probe count
Detour queriesOn detour recheck interval while hybrid movement is activeNav path length vs straight line
Action evaluationEvaluationCooldown (default 0.1 s on native brain / Poll Action)Scorer count per action
Action execution tickOnly while an action runs and a hook sets bWantsTickCustom hook work
Role subsystemRoleReassignmentInterval (project default 8 s)Combatant × role candidate count
Threat detectionEvery tick by default; throttle with SetTickIntervalDot product on focus actor
AwarenessEvaluationInterval on config (default 0.1 s)Perceived actor count
Melee traceTick only between StartTracing and StopTracingActive socket count

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):
StatScope
MovementEvaluator - TotalFull per-AI movement pass
MovementEvaluator - Direction ScoringSample loop over NumSamples
MovementEvaluator - AvoidanceThrottled overlap scoring
MovementEvaluator - Nav SamplingNav validity cache refresh
MovementEvaluator - Detour QueryPath-length detour check
RoleSubsystem - Role DistributionGlobal role assignment pass
ThreatDetection - TickPer-tick threat level
Unreal Insights: filter CPU trace events SEC_MovementEvaluator, SEC_DirectionScoring, SEC_Avoidance, SEC_NavSampling, SEC_DetourQuery, SEC_RoleDistribution, SEC_ThreatDetection.
For log-based diagnosis, see Debugging & Troubleshooting.

Optimizations Already in Code

  1. Unit-circle sample cache: trigonometry for direction samples is precomputed when NumSamples changes.
  2. Throttled avoidance: overlap queries run at 10 Hz, not every frame.
  3. Throttled nav cache: NavCheckInterval plus NavStaggerStride spread nav sweeps across frames in a pack.
  4. Timer-based roles: reassignment runs on RoleReassignmentInterval, not per frame.
  5. Hybrid movement: strategic pathfinding only past HybridSwitchDistance (or while detour escalation is active).
  6. Conditional melee tick: USECMeleeTraceComponent starts with tick disabled; tracing enables tick only for active swings.
  7. Conditional action tick: ActionEvaluationComponent ticks only during action execution (hook dispatch), not while idle.

Scaling Guide

Rough totals from the cost model above (movement + threat + small avoidance/role share). Measure your encounter in PIE before shipping horde modes.
ScenarioActive SEC enemiesEstimated plugin CPU
Soulslike duel1–5< 0.02 ms
Action RPG pack10–20~0.05–0.1 ms
Horde50–100~0.2–0.4 ms
Stress test150+~0.6 ms+
Cost scales roughly linearly with enemies that run movement + threat every frame. Idle or off-mesh actors cost less.