Beschreibung
Enemies that break, run, and come back - without a single frame of flicker.
THE PROBLEM
Enemies that fight to the last man read as machinery. Everybody knows it, and everybody’s first fix is the same: a float, a threshold, a bool. That fix reads as a bug, because an agent hovering at the threshold flips between brave and terrified every frame - and every flip fires a delegate, a bark and an animation. The symptom is never reported as "morale is wrong". It is reported as stuttering.
WHAT IT IS
That float done properly. Four states rather than two, because a Shaken agent still fights - from cover, at longer range, with worse aim - and that is where most of the character lives. A hysteresis band, so the level at which somebody breaks is not the level at which they rally. And a minimum dwell time on top of it, because a burst of four events in one frame can jump clean across the band.
NERVE, AND CONTAGION
Every agent gets a private nerve, rolled once at spawn and never again, so the same bad news moves a steady man less than a nervous one. Without it a squad breaks in unison like a single organism; with it, one man runs first and the others watch him do it.
And panic is contagious: each agent is pulled towards its squad’s average. One man breaking drags the average down, which drags everybody down, which breaks the next one. That feedback loop is the difference between "three enemies happened to flee" and "the line broke".
FRAME-RATE INDEPENDENT, AND PROVABLY SO
The contagion is an exponential approach, so one second is one second whether your frame took 8 ms or 33. There is an automation test that asserts two half-steps land exactly where one whole step does. The version everyone writes first fails that, and the bug ships as "panic spreads faster on my machine than on the build server".
REASONS TRAVEL
The state change carries the reason, so the squad that breaks because its sergeant died can say something different from the one that breaks because it is outnumbered. Event weights live in a table in Project Settings, so tuning how brittle an army is does not need a programmer - and a row deleted from the table is an event switched off.
WHAT IT DOES NOT DO
It does not move anybody: Routed is a state and a delegate, and where the agent runs is your navigation. It is not a behaviour tree - no task nodes, no decorators, no blackboard keys - so projects on StateTree, on GAS or on hand-written controllers all work with it unchanged.
Unreal Engine 5.8, one runtime C++ module, Win64, no AIModule or GAS dependency. Blueprint-first throughout. Six automation tests over the rules that fail quietly. A demo level that runs without pressing play. Full source included.





