Reaction System

Documentation Unreal Engine AI Reactions

Give an enemy an answer to what happens to it: author a reaction, point a trigger rule at the event, and it parries, dodges or flinches on its own.


An enemy that answers your swing instead of eating it. One asset holds the answers and the rules that pick between them.

Set it up

60 seconds
  1. 1

    Create a Reaction Set

    Right-click in the Content Browser, SEC, Reaction Set. It opens on its own card canvas.
    Content Browser
    Content
    Right-click in the Content Browser, SEC, Reaction Set.
  2. 2

    Add the reaction

    Right-click the canvas and choose Add Reaction. A card appears carrying a Reaction ID and a Gameplay Ability execution method already on it. Name the Reaction ID Parry.
    Set Ability Class to GA_SEC_MontageAbility, which ships with the plugin. A Montage Payload appears underneath it; set its Montage to your parry animation.
    DA_ReactionSet_Grunt
    Execution
    Ability ClassNone
    Montage
    None
    The shipped ability plays whatever montage the reaction names.
  3. 3

    Say which event it answers

    Right-click the canvas again and choose Add Trigger. Set its On Stimulus to SEC.Stimulus.AttackTelegraphed, then drag from the pin on the right of the trigger card to the pin on the left of the Parry card.
    That arrow reads: when an attack winds up nearby, parry it.
  4. 4

    Point the AI Config at it

    Open the enemy's Enemy AI Config and set Default Reaction Set to the asset. Leave Manage Reaction Sets Automatically ticked.
    EnemyConfig_Grunt
    Reaction Sets
    Manage Reaction Sets Automatically
    Default Reaction Set
    None
    Default Reaction Set covers every role, so one entry is enough to start.
  5. 5

    Make the attack announce itself, and play

    Open the player's attack montage and add the SEC Attack Telegraph notify where the wind-up starts. That notify is what tells nearby enemies a blow is coming.
    Press Play, swing at the enemy, and run SEC.Debug.LogReactions 1 to read which rule answered and which reaction won.
Nothing reaches an enemy until an attack announces itself. A montage without a SEC Attack Telegraph notify sends no warning, so the trigger rules never run and the enemy stands there taking hits. Turn on SEC.Debug.Stimulus.Draw 1 to see whether anything is going out at all. See Attack Telegraphs.
An enemy answers a stimulus whether or not it has a combat target, so a patrolling enemy can parry the first swing of an ambush.

Say what answers each event

Trigger Rules on the Reaction Set turn an event into an answer. The enemy asks them in Rule Priority order, highest first, and takes the first rule that fits and yields a reaction, so specific rules sit above general ones.
Trigger
Enabled
Rule ID
ParryFrontal
On Stimulus
SEC.Stimulus.AttackTelegraphed
Require Context Tags
0 Gameplay Tags
Block Context Tags
1 Gameplay Tag
SEC.Attack.Unblockable
Conditions
1 Array element
Index [ 0 ]
Incoming Angle Gate
Incoming Angle Gate
Half Angle Degrees
60.0
Pass Without Direction
Invert
Answers
Reaction Links
2 Array elements
Reaction Category
SEC.Reaction.Defensive
Rule Priority
20
Chance
0.60
Min Interval
1.5
FieldSets
Rule IDShort name, shown in the row title and in the log when the rule fires or is skipped: ParryFrontal, DodgeUnblockable.
On StimulusWhich event this rule answers. A rule on a parent tag catches everything beneath it, so one on SEC.Stimulus.AttackTelegraphed also answers your own SEC.Stimulus.AttackTelegraphed.Heavy.
Require Context TagsThe event must carry all of these, which is how a rule answers heavy attacks alone. Empty requires nothing.
Block Context TagsThe rule steps aside when the event carries any of these, so a parry rule refuses SEC.Attack.Unblockable and the dodge rule below it answers.
ConditionsGates that all have to pass before the rule answers. A refused rule hands the event to the rule below it.
ChanceHow often the rule fires when everything else fits, 0 to 1. Drop it to 0.3 and the enemy parries roughly a third of the swings.
Min IntervalShortest gap in seconds between two firings, so an enemy cannot parry every swing of a fast combo. 0 sets no limit.
Two shipped stimulus names cover the common cases: SEC.Stimulus.AttackTelegraphed for a swing winding up, and SEC.Stimulus.DamageTaken for a blow that already landed. Author child tags of either for an attack that needs its own answer.

Which reactions a rule can answer with

Draw an arrow to each reaction the rule may pick, or name a group instead with Reaction Category and let every reaction carrying that category compete. Fill in both and the rule answers only with a reaction that is wired and carries the category, which narrows the field.
Each arrow carries a Weight Multiplier: 1 leaves the reaction's own weight alone, 2 makes this rule lean twice as hard on that answer.

One rule, two answers

Wire a rule to both Parry and Dodge, then put an Incoming Angle Gate and the higher Priority on Parry. A frontal blow gets parried, and a blow from the side falls to the dodge with no second rule.

Laying this out as cards and watching a live enemy answer is what the Reaction Set Editor is for.

Author the reaction

A reaction card carries what runs, what it holds while it runs, and how often it may run.
Identity
Enabled
Reaction ID
Parry
Reaction Category
None
Execution
Execution Method
Gameplay Ability
Ability Class
GA_SEC_MontageAbility
Payload
Montage Payload
Montage
AM_Parry
Cancel Current Action
Tags
Add Tags
0 Gameplay Tags
Requires Tags
0 Gameplay Tags
Block Tags
0 Gameplay Tags
Scoring
Priority
0
Selection Weight
1
Scoring
0 Array elements
Action Interaction
Cancel Current Action
Execution Method is how the reaction runs, the same picker actions use. Gameplay Ability covers almost everything: name an ability class, fill in its payload, and the reaction is set up. Gameplay Ability By Tag starts an ability something else already granted. Gameplay Ability (Fire And Forget) starts one and finishes in the same frame, for a shout the enemy should not stand still for.
Add Tags sit on the enemy while the reaction runs and come off when it ends. Put SEC.Action.BlockActions there to freeze the moveset for the duration.
Cancel Current Action is on by default, so a reaction cuts the swing the enemy was mid-way through. Untick it for a flinch that should play over the top.
Cooldown Duration is the wait before the same reaction can run again, 0 by default. Randomization (%) jitters it so a pack does not parry in lockstep, and Max Consecutive Uses forces a different answer after a set number of repeats.
Nothing has to report back. SEC watches the ability system for the ability it started, so any ability that reaches End Ability on completion, cancel and interrupt works with no extra wiring. An ability still running after 30 seconds is cut off; set Ability Timeout to cap it sooner.
One reaction runs at a time. A second one asked for while the first is going is refused outright, so a reaction that never ends mutes the enemy until the safety limit expires.
AdvancedReading the hit direction to pick a montage section
GA_SEC_Reaction ships as the directional variant. It plays one montage and picks the section by the direction the blow arrived from, which is how a single hit reaction covers front, back and both sides.
It carries the montage as a class default rather than a payload, so make a Blueprint subclass per hit reaction and set Reaction Montage on it.
AdvancedStop two reactions overlapping
Put the same tag in one reaction's Add Tags and another's Block Tags. SEC.State.ReactionActive ships for this, and nothing adds it on your behalf.

Parry reaction

Adds SEC.State.ReactionActive while it runs. No block tags.

Tags
Add Tags
1 Gameplay Tag
SEC.State.ReactionActive
Requires Tags
0 Gameplay Tags
Block Tags
0 Gameplay Tags

Dodge reaction

Same add tag, plus Block Tags so it cannot fire during Parry.

Tags
Add Tags
1 Gameplay Tag
SEC.State.ReactionActive
Requires Tags
0 Gameplay Tags
Block Tags
1 Gameplay Tag
SEC.State.ReactionActive
While Parry runs it holds the tag, so Dodge is refused until Parry ends and the tag comes off.

Pick between several answers

When a rule can answer with several reactions, they compete. Gates run first and drop the reactions that cannot help, scorers scale each survivor's weight, the highest Priority band takes the field, and a weighted random picks inside that band.
Reaction Evaluation Flow
Content>Plugins>SoulslikeEnemyCombat>Components
Waiting for stimulus…
Stimulus (Your Code)
OnDamageReceived, OnSenseDetected…
EvaluateBestReaction(Category)
Gates → Scorers → Priority → Weighted random
Cancel Current Action
StopCurrentAction() if bCancelCurrentAction
ExecuteReaction(Id, Context)
AddTags → Pack context → Activate ability
OnReactionCompleted
Remove AddTags → Fire delegate → Reset
Reactions are event-driven — your code decides when, the system decides what. Every 3rd cycle shows a blocked reaction.
Scoring
Priority
0
Selection Weight
1
Scoring
0 Array elements
FieldDoes
PriorityThe band. A reaction in a higher band beats every reaction below it, whatever the weights say.
Selection WeightThe odds inside a band. Weight 2 is twice as likely as weight 1.
ScoringGates that veto the reaction, and scorers that scale its weight.
A scorer that drives a weight to zero vetoes the reaction outright, even at a high priority.

Scorers on reactions

Reactions take the same scorers and gates as actions, reading live distance, angle, speed and the pawn's vitals at the moment the blow arrives. Each built-in scorer shapes its dimension through one Range curve:
Range
Min Value
0
Optimal Min
100
Optimal Max
250
Max Value
500
Exponent
2
Clamp To Zero
Four gates read the event rather than the pawn, so each one works either on a reaction's Scoring or in a rule's Conditions:
GateBlocks unlessDefaults
Incoming Angle GateThe blow arrives inside an arc in front of the pawn.Half Angle Degrees 60, so anything up to 60 degrees off the front passes; 180 turns it off. Pass Without Direction on.
Time To Impact GateThere is still time to answer before the blow lands.Min Seconds 0, Max Seconds 0 (no bound). Set Min Seconds to the parry's own start-up.
Stimulus Magnitude GateThe blow is worth answering, in whatever the producer measured.Min Magnitude 0, Max Magnitude 0 (no bound). A ceiling on one and a floor on the next splits a flinch from a stagger.
Source Distance GateThe source is within reach, in centimetres.Min Distance 0, Max Distance 0 (no bound). Pass Without Source on.
The two placements read differently. A gate on a rule's Conditions decides whether this kind of answer is considered at all, and a refusal sends the event to the next rule down. A gate on a reaction's Scoring decides whether this reaction is the right one among the others that matched.
An action carries no event, so one of these four added to an action has nothing to judge and passes.
AdvancedWriting a gate or scorer of your own
Subclass SEC Scorer or SEC Gate in Blueprint or C++ and override its one function. The context hands you the controller, the target, the ability system component, and a snapshot carrying distance, angle, speed, health, stamina and the event that set the reaction off.
Keep subclasses stateless. Every enemy using the asset shares one instance, so a stored field aliases across the whole pack. The seeded random helper is fixed on the reaction path, so use the world's random for per-enemy variation.

Which Reaction Set an enemy uses

Fill in Default Reaction Set on the AI Config and every combat role uses it. Beyond that, four things can answer instead, and the first match wins:
SourceUse it for
Runtime OverrideBoss phase transitions. Set it in Blueprint, clear it to fall back.
An equipped weaponReactions that come with what the enemy is holding, such as a parry it can only do with a sword.
Role Reaction SetsA different set per combat role, so a Waiter guards more than an Attacker.
Default Reaction SetEverything else.
A weapon carries its set in Weapon Reaction Set on the weapon Blueprint. While the enemy holds it, that set wins; drop the weapon and the enemy falls back to its config. See Weapons.
The set is resolved when the controller possesses the pawn and again on every role change, and each reaction's ability is granted as the set arrives. An enemy standing idle can answer a stimulus before it has picked a combat role.
Author Role Reaction Sets without a Default Reaction Set and an enemy that has not been assigned a role gets nothing. Fill in the default as well.
AdvancedSwapping a set while a reaction is running
A swap takes a mode. Immediate cancels the running reaction and swaps now, which is the default. Wait For Completion queues the swap and applies it when the reaction finishes, so a boss phase change does not cut a parry in half. Both Set Runtime Override and Clear Runtime Override take it.
Set Provided Reaction Set drives the weapon slot directly for a pawn running its own equipment, and passing nothing falls back to the config. Override Get Weapon Reaction Set For Role on the weapon to vary it per role; a weapon deriving from something other than SEC Weapon Base adds the SEC Weapon Reaction Set Provider interface in Class Settings.
AdvancedPer-enemy setup without the base classes
Two components carry reactions. Reaction Evaluation sits on the AI controller and does the choosing and the running. SEC Reaction Set sits on the pawn, resolves which set applies, and replicates the state a HUD reads.
Enemy Controller Base and Enemy Character Base ship with them. A custom controller and pawn need them added by hand.
For a pawn with no AI Config at all, Default Reaction Set on the pawn's SEC Reaction Set component is the last link in the chain and enough for a test.

Debug it

SEC.Debug.LogReactions 1        // Which rule answered, which declined and why, which reaction won
SEC.Debug.Reactions 1           // Reaction list above each enemy, with priorities and cooldowns
SEC.Debug.Stimulus.Draw 1       // The announced shape, and every pawn it reached
SEC.Debug.All 1 turns every overlay on at once, and SEC.Debug.WatchPawn <name> narrows them to one enemy.
Two of them have a per-enemy equivalent that needs no console: Debug Log Reactions on the Reaction Evaluation component, and Debug Overlay Reactions on the pawn's SEC Reaction Set component.
Saving the asset runs validation, which reports into the Asset Check message log and names any reaction with nothing to run.
AdvancedThe attack lands and the enemy does nothing
Read SEC.Debug.LogReactions 1 first; it names the stage that refused. In the order worth checking:
  • Nothing was announced. The attacker's montage has no telegraph notify, so no event ever arrived. SEC.Debug.Stimulus.Draw 1 shows whether anything goes out.
  • The enemy did not notice. Stimulus Filters on the AI Config decide that, and a facing cone or a line of sight filter refuses a blow the enemy could not see. See Attack Telegraphs.
  • No rule matched. The rule's On Stimulus tag has to match the tag the announcement carries, and a context tag can block it.
  • The rule matched and found no answer. Every reaction it names was on cooldown, disabled, or refused by a gate. The canvas flags a rule wired outside its own category, which answers nothing at all.
  • A reaction is already running. One runs at a time, and a second request is refused.
  • SEC.Reaction.BlockReactions sits on the enemy. That mutes reactions outright.
AdvancedWhat silently drops a reaction before it is picked
Identity
Enabled
Tags
Requires Tags
0 Gameplay Tags
Block Tags
0 Gameplay Tags
Cooldown
Cooldown Duration
5
Initial Cooldown
0
Randomization (%)
0.2
Interrupt Refund (%)
0
Spawn Cooldown Chance
0
Max Consecutive Uses
-1
CauseDrops the reaction when
EnabledIt is toggled off.
No execution methodNothing is set, or the method is missing data it needs.
Behavior Tree SequenceA reaction interrupts what the AI is doing rather than replacing its brain, so that method is refused.
Cooldown or repeat limitIt is still cooling down, or Max Consecutive Uses is spent.
SEC.Reaction.BlockReactionsThe tag sits on the enemy's ability system component.
Requires Tags / Block TagsThe enemy's own tags do not line up. Reactions read the enemy's tags alone, not the target's or the world's.
A gateAny gate in Scoring answered no.
The same checks run at selection and again when the reaction starts, so one that stops qualifying in between is dropped rather than started.

AlternativeFiring a reaction from your own Blueprint
When your game already knows which answer fits, call the controller's Reaction Evaluation component directly and leave the trigger rules out of it.
Execute Reaction takes the Reaction ID and a context struct. Fill in Target with the attacker, Magnitude with the damage, and Event Tag with your own category; the ability reads all of it back through Get Action Context.
Can React runs the same checks without executing, for a check ahead of time. Pass the attacker as the target override so distance and angle gates measure against it.
On Stimulus Received fires for everything the enemy notices, before the rules look at it. Call Execute Reaction from that binding and the rules sit the event out, since a rule fires only when nothing already answered. That is the opt-out for a project routing events its own way.
A Reaction Set with no rules authored answers nothing by itself, which leaves this as the only way in.
AdvancedReplacing the perception or the routing step
Two overridable events on a Blueprint or C++ subclass of the Reaction Evaluation component each take over one stage.
OverrideReplaces
Can Sense StimulusThe whole perception step. The default runs every filter in force and requires all of them to pass.
Select Reaction CategoryThe whole rule walk. Return a category tag to route an event your own way without authoring rules.
Evaluate Best Reaction For Stimulus is the selection the rules run, with the event carried down so gates and scorers can read which way the blow is arriving. Evaluate Best Reaction Among Links narrows that same selection to a named few and applies each link's weight multiplier.
Fallback Stimulus Filters on the component covers a pawn running without an AI Config. A config listing any filters replaces that list outright rather than adding to it.
AdvancedWhat a reaction hands its ability
Both actions and reactions pass the same context struct through to the ability, which reads it with Get Action Context.
FieldCarries
TargetWho caused it. Filled in from the event's source for a reaction the rules fired.
Optional ObjectThe weapon, the projectile, the item.
MagnitudeDamage, charge level, intensity, in the producer's own units.
Event TagWhich category set this off.
Context TagsSituational tags such as an unblockable marker.
Target DataSpatial payload, packed with the target data helpers.
StimulusWhat set this off, filled in for a reaction the rules fired and empty for one started by hand.
Distance and direction to the target are filled in when the ability activates, along with both sides' gameplay tags.
Override Can Activate Ability on the ability, read the context, and return false to refuse. A refusal costs nothing: no cooldown is charged and no running reaction is interrupted.
MultiplayerMultiplayer
Reactions are chosen and run on the authority. Receive Stimulus is server side, and the telegraph notify returns early on any machine that is not the server, so a montage playing on a client announces nothing.
The pawn's SEC Reaction Set component replicates what a client needs: the running reaction, the active set, the cooldowns, and delegates for reaction started, completed, set changed, and cooldown started and expired. Bind those for a HUD or client-side effects. See Multiplayer.

PageWhy
Attack TelegraphsWhere the events come from, how far they carry, and which enemies notice.
Reaction Set EditorThe canvas the rules and reactions are wired on.
Action SystemThe poll-driven side, and the scorers and gates both share.
Defense SystemWhat the raised guard is worth once the blow arrives.
VitalsThe health and stamina the scorers and gates read live.