Defense System
Documentation Unreal Engine AI Defense Combat
Give a pawn a guard: create a Defense Rule Set, author one response, and an incoming hit is parried, blocked or ignored before it reaches health.
A pawn carries an ordered list of answers to an incoming hit. The first one that fits decides what the blow was worth and reports back, so the attacker can tell a parry from a block.
Set it up
60 seconds- 1
Add the Defense component
Select the pawn, Add Component, SEC Defense. An enemy built onEnemyCharacterBasealready carries one named Defense; select that instead of adding a second. - 2
Create a Defense Rule Set
Right-click in the Content Browser, SEC, Defense Rule Set.Content Browser▸ ContentRight-click in the Content Browser, SEC, Defense Rule Set. - 3
Author one response
On the asset, press + on Responses and pick SEC Block. Set Required Tags to the tag the guard holds while it is up, and Result Tag toSEC.Defense.Blockso the attacker learns what happened.DA_Defense_KnightArmour▾BlockRequired TagsResult TagRequired Tags and Result Tag both ship empty, so they are the two to fill in. The 60 degree arc and the 0.2 multiplier ship ready to use. - 4
Point the Defense component at it
Select the pawn's SEC Defense component and set Defense Set to the asset.SEC Defense▾SEC|DefenseDefense SetNone▾Defense Set answers after everything authored directly on the component, which ships empty. - 5
Answer Handle Incoming Damage
In the pawn's Class Settings, add the SEC Damageable interface, then implement Handle Incoming Damage with one node. Resolve Defense and Apply Damage runs the responses, charges what they cost, takes what survived off the pawn's health pool, and reports back.BP_PlayerCharacter · SEC Damageable interfaceEvent Handle Incoming DamageDamage InfoResolve Defense and Apply DamageTarget is SEC Defense StaticsDefenseSEC DefenseDamage InfoHealth Vital TagSEC.Vital.HealthReturn ValueReturn NodeReturn ValueSet Health Vital Tag on the node to the pawn's health pool,SEC.Vital.Healthin the tags the plugin ships. The pin starts empty, and the pawn needs a SEC Vitals component carrying a row for that tag; without either one the node resolves the hit and drains nothing. See Vitals.Enemies built onEnemyCharacterBaseanswer this already, so skip this step there. - 6
Play, and hit it while the tag is held
A fifth of the damage lands, and the swing comes back carryingSEC.Defense.Block. Drop the tag and the same blow lands whole.
A response answers only while the pawn holds the tags in its Required Tags, and nothing in the plugin puts them there. A guard ability, a reaction, or a montage window has to hold one while the guard is up. Until something does, the response sits inert and hits land at full damage.
A response only that one pawn needs does not need the asset. Press + on the component's own Responses instead of creating a Defense Rule Set, using the same Required Tags and Result Tag fields. Responses authored there run ahead of the Defense Set, so the two combine rather than compete.
A Defense component with nothing authored and no Defense Set reports the incoming damage unchanged, so dropping it onto an existing pawn changes nothing until you write the first response.
The responses that ship
Add them to Responses in this order to start from a sane list: most situational at the top, the scaling ones at the bottom.
| Response | Answers when | Ships with |
|---|---|---|
| SEC Invulnerable | The pawn holds the tags. No arc, so it answers from every direction, and no cost. | Damage fixed at 0 |
| SEC Parry | The pawn holds the tags and the blow arrives inside the arc. | 90 degree half arc, multiplier 0 |
| SEC Block | The pawn holds the tags and the blow arrives inside the arc. | 60 degree half arc, multiplier 0.2, cost per damage 1 |
| SEC Damage Modifier | The pawn holds the tags, whatever the attack is. Scales a hit by what the pawn is: double against a stance-broken enemy, half against a buffed one. | Multiplier 1, Continue After Claim on |
| SEC Damage Type Resistance | The attack's damage type matches. Armour and elemental resistance. | Multiplier 1, Continue After Claim on |
The last two scale a hit rather than answering it, so a blow only they touched still reads as unguarded to the attacker.
Where the tags come from
A response reads the pawn's current state tags and nothing else. Whatever grants a tag decides when the response is live: a reaction on an enemy, an input-driven ability on a player, or a montage window that holds a tag for the frames it covers.
That is the seam between the two halves of a defence. The reaction picks the animation and plays it; the response prices a hit that lands during it. One enemy parry reaction plus one SEC Parry response covers the whole move, and neither knows about the other beyond the tag they share.
Author a response
What a guard reads
SEC Parry, SEC Block, and SEC Invulnerable share these fields.
| Field | Sets |
|---|---|
| Required Tags | Tags the pawn must all hold for this to answer, which is what the parry, guard, or dodge ability grants while it runs. Empty answers without a tag gate. |
| Blocked Tags | Tags that stop this answering when the pawn holds any of them, such as a stagger. Empty stops nothing. |
| Arc Half Angle Degrees | Half the width of the arc the blow must arrive inside, in degrees to either side of straight ahead. 60 accepts anything up to 60 degrees off the front, 180 accepts all round. A blow carrying no direction counts as frontal, so an attack with none cannot slip past a raised guard. Parry starts at 90, Block at 60. SEC Invulnerable has no arc. |
| Damage Multiplier | How much of the hit still lands. 0 stops it completely, 0.2 lets a fifth through as chip damage, 1 changes nothing. Parry starts at 0, Block at 0.2. |
| Result Tag | What to call this answer, reported to the attacker so its swing and its impact effects can react. |
What every response carries
These sit on the base class, so each kind has them.
| Field | Sets |
|---|---|
| Continue After Claim | Keep running the responses below this one after this one answers, so a resistance can shave what a block let through. Off on SEC Parry, SEC Block and SEC Invulnerable, which is what a parry wants, and on for the two scaling kinds. |
| Cost Vital Tag | Vital this answer charges, such as stamina for a raised guard. Leave it unset and the answer is free, which also means the pawn needs no vitals at all. |
| Flat Cost | Units charged per hit, whatever the blow was worth. Ignored while Cost Vital Tag is unset. |
| Cost Per Damage | Extra units charged per point of incoming damage, measured against the blow before anything reduced it. 1 charges the whole hit to the vital, 0 turns the scaled part off. Ignored while Cost Vital Tag is unset, so the 1 that SEC Block ships with charges nothing until you point that field at a pool. |
| Vital Damage Multipliers | Channels this response treats differently from health. Empty and one Damage Multiplier covers every channel, so a block that halves health halves stance with it. Add a row to let stance or poise through at its own rate. |
Working out the answer spends nothing. The component charges what the responses cost afterwards, which is what lets Preview Incoming Damage run the same walk on any machine and show a player what a hit would cost before it lands.
Worked examples
Frames where the pawn takes nothing
Give the ability a tag while it runs, put SEC Invulnerable at the top of the list, and point Required Tags at that tag.
Details
SEC Invulnerable
Invulnerable
Required Tags
1 Gameplay Tag
SEC.State.Invulnerable
Blocked Tags
0 Gameplay Tags
Result Tag
SEC.Defense.Block
Cost
Cost Vital Tag
None
Flat Cost
0
Cost Per Damage
0
Defense Rule
Continue After Claim
Takes the hit for nothing while the pawn holds the tag. No arc, so it answers from every direction, and no cost.
Damage is zero from any direction, at no cost.
SEC.State.Invulnerable ships as a starting tag for a boss in an immune phase or an actor a script has put out of reach. The blow still lands, still plays its impact effect, and still reports back.For the invulnerability frames of a dodge, where a sweep should attempt nothing at all, list
SEC.State.Intangible in Pass Through Tags on the attacker's melee trace instead. That tag is already in the shipped list, so a montage window holding it across the roll is the whole setup. Reach for SEC Invulnerable when the hit has to resolve, or when damage arrives from something other than a sweep.A parry, front only
Give the parry ability a tag while its window is open, put SEC Parry above the block, and narrow the arc to the front.
Details
SEC Parry
Parry
Required Tags
1 Gameplay Tag
Player.State.Parrying
Blocked Tags
0 Gameplay Tags
Arc Half Angle Degrees
60
Damage Multiplier
0.00
Result Tag
SEC.Defense.Parry
Cost
Cost Vital Tag
None
Flat Cost
0
Cost Per Damage
0
Defense Rule
Continue After Claim
Answers only while the parry ability holds its tag and the blow arrives inside 60 degrees of straight ahead.
A blow from the front inside the window does nothing. A blow from behind falls through to whatever sits below, which is how a parry and a block coexist without either of them naming the other.
A block that costs stamina
Give the guard ability a tag it holds while the guard is up, put SEC Block under the parry, and point Cost Vital Tag at the stamina pool.
Details
SEC Block
Block
Required Tags
1 Gameplay Tag
Player.State.Guarding
Blocked Tags
1 Gameplay Tag
Player.State.Staggered
Arc Half Angle Degrees
60
Damage Multiplier
0.20
Result Tag
SEC.Defense.Block
Cost
Cost Vital Tag
SEC.Vital.Stamina
Flat Cost
5
Cost Per Damage
1
Defense Rule
Continue After Claim
Charges 5 stamina plus 1 per point of the incoming blow. A pawn that cannot pay drops through to whatever sits below.
A response's charge is Flat Cost plus Cost Per Damage times the blow before anything reduced it. The values above cost 45 stamina against a 40 damage swing.
Running out is a guard break. Before a costed response answers, the component asks whether the pawn can pay. One that cannot pay steps aside and the next response down takes the hit, so an exhausted pawn eats the blow at whatever the responses under the block make of it. Two responses drawing on one vital are measured against a running total, so a pool that covers one of them does not cover both.
The pool comes from the pawn's Vitals component. A pawn with a costed response and no vitals component answers for free and names itself once in the Output Log.
Armour
Details
SEC Damage Type Resistance
Damage Type Resistance
Damage Type Tag
SEC.Damage.Physical.Slashing
Damage Multiplier
0.60
Result Tag
None
Cost
Cost Vital Tag
None
Flat Cost
0
Cost Per Damage
0
Defense Rule
Continue After Claim
Shaves 40 percent off slashing damage and carries on down the list, so it trims whatever the guards above it let through.
| Field | Sets |
|---|---|
| Damage Type Tag | Which kind of damage this resists, matched off the attack's own damage type. A parent tag covers everything beneath it, so SEC.Damage.Physical resists slashing, piercing, and bludgeoning at once. Leave it unset to scale every hit, which is flat armour. |
| Damage Multiplier | How much of the hit still lands. Starts at 1, which changes nothing. |
| Result Tag | Leave it unset for plain armour, which shaves the damage without telling the attacker anything. |
This kind answers by what the attack is rather than by what the pawn is doing, which is why it ships with Continue After Claim on and a hit that only armour touched still reads as unguarded. Melee Trace covers the damage type vocabulary and where an attack picks its type.
Where the responses come from
Most situational firstA hit enters at the top
1
What the pawn is carrying
Weapon Defense Set on each held item, gathered through Get Defense Sets
Runs in the order the items were equipped, and stops the moment an item is put down. A shield in the off hand contributes alongside the sword.
2
Responses on the component
SEC Defense > Responses
The pawn's own answers: its dodge frames, its parry, its stance. Authored on the pawn, so they hold whatever it is holding.
3
The shared set
SEC Defense > Defense Set
A Defense Rule Set several characters point at. Last in the walk, so a broad resistance here trims whatever the answers above it let through.
The first response that answers the hit ends the walk. Tick Continue After Claim on a response and the ones below it keep shaving what is left, which is what armour wants and a parry does not.
| Field | Sets |
|---|---|
| Defense Set | A shareable list of responses, for armour or a stance several characters use. Runs last, under everything in Responses, so a broad resistance here shaves whatever the answers above it let through. Empty means everything is authored on this pawn. |
| Responses | Responses authored on this pawn alone, running after whatever the pawn is carrying brings and before the Defense Set. |
Details
SEC Defense
SEC|Defense
Defense Set
DA_Defense_KnightArmour
Responses
3 Array elements
Responses run top down. Whatever the pawn is carrying answers first, then these, then the Defense Set.
Pointing several characters at the same set
Set more than one Defense component's Defense Set to the same asset,
DA_Defense_KnightArmour from the walkthrough above or a copy authored for another archetype, to give every pawn carrying it the same answers. Edit the asset once and every pawn pointed at it picks up the change.A weapon that brings its own
Fill in Weapon Defense Set on a weapon Blueprint built on
SECWeaponBase and point it at a rule set holding the parry, the block, or whatever the weapon is worth. Arm the enemy through the equipment component's Starting Loadout or an Equip Actor call, and it answers with those for as long as it holds the item.A shield in the off hand works the same way. Everything held that carries a set contributes, in the order the pawn equipped them, and all of them answer ahead of the pawn's own responses.
EnemyCharacterBase gathers them from its equipment already. See Weapons.Telling the attacker what happened
Every response that answers adds its Result Tag to the result, and that reaches the attacker in the damage result's Result Tags. Two things read them.
The attacker's melee trace. Skip Record Tags on the attacker's trace component lists the outcomes that leave the target hittable for the rest of the swing. A match means the swing was not spent, so it can connect again on a later frame. No match records the hit, so a parry or a block costs the attacker that swing. Both readings are legitimate; pick per game. See Melee Trace.
Hit effects. An effect on the damage config sits out a hit through Suppress On Result Tags, so a parried blow need not shake the screen or spray blood. Require Any Result Tags does the opposite and gives a parry its own sparks.
Four tags ship:
SEC.Defense.Parry, SEC.Defense.Block, SEC.Defense.Dodge, and SEC.Defense.Clash. A tag of your own works the same way, and listing a parent covers everything beneath it.A parry, block or invulnerable response that answers a hit without a Result Tag leaves the attacker unable to tell what happened, so the swing is spent as if the blow had landed. The Output Log names the response once when that happens.
Debug it
Press Play and swing at the pawn with the tag held, then without it.
SEC.Debug.Melee.DrawTracing 1 // The attacker's sweep, so you can see the blow reach the pawn
Filter the Output Log to LogSECCore. The defense path names each problem once rather than every frame, and the four it reports cover most of what goes wrong: a response that charges a vital the pawn has no component for, a response that answered without a Result Tag, a pawn with no health pool to take the damage off, and an attack listing the health pool as an extra damage channel.
Preview Incoming Damage on the component reaches the same answer as the real resolve and charges nothing, so a debug widget can print what any hit would cost before it lands.
AdvancedThe pawn is hit and nothing changes
In the order worth checking:
- Nothing grants the tag. Required Tags names a tag no ability, reaction or montage window ever holds, so the response never gets its turn. This is the common one and it logs nothing.
- Handle Incoming Damage is not implemented. Without the SEC Damageable interface on the pawn, SEC Deal Damage falls back to Unreal's point damage and the Defense component never runs.
- The blow came from outside the arc. Parry and Block measure the direction the hit arrived from against the pawn's real facing. A hit from behind falls through to whatever sits below.
- The pawn cannot pay. A costed response the pawn cannot afford steps aside on purpose, which is the guard break.
- A response above it claimed the hit. The first response that answers ends the walk unless it has Continue After Claim ticked.
- The call ran off the server. Charging a cost and draining health both need the authority.
AdvancedStance, poise and other damage channels
An attack can carry damage to pools other than health. One Damage Multiplier covers every channel by default, so a block that halves the health damage halves the stance damage with it.
Add a Vital Damage Multipliers row on the response to give one channel its own rate: name the channel's vital tag and set how much of it still lands. 0 stops that channel, 1 passes it untouched, and above 1 raises it, which is how a block that costs extra stance is authored.
The health figure and the extra channels are both reported after the walk, so a project applying them by hand has each of them separately. See Vitals.
AdvancedScaling a hit by what the pawn is
SEC Damage Modifier takes Required Tags and Blocked Tags but no arc, and multiplies the hit by Damage Multiplier: 2 doubles it, 0.5 halves it, 1 changes nothing.
It ships with Continue After Claim on and leaves the outcome alone, so a hit that only this touched still reads as unguarded and the attacker's swing is spent normally. Gate it on
SEC.State.StanceBroken for the window where a guard-broken enemy takes extra, or on a buff tag for a target that takes less.Its multiplier applies to every channel the hit carries, so pair it with a Vital Damage Multipliers row when one channel should scale at its own rate.
AdvancedBringing responses in from somewhere other than a weapon
Two interfaces cover the rest of the cases, and both are Blueprint-implementable from Class Settings.
| Interface | Where | What it answers |
|---|---|---|
| SEC Weapon Defense Set Provider | On the item | Get Weapon Defense Set, for an equippable that is not a weapon Blueprint. |
| SEC Defense Set Provider | On the pawn | Get Defense Sets, one entry per thing in force, for a pawn that gathers its own way. |
The component stores nothing. It asks the pawn each time it works a hit out, so a set stops answering the moment the pawn stops carrying what brought it. Returning an empty list leaves the pawn on its own responses.
For a list built some other way again, override Get Effective Responses on the component and return the responses in the order you want them run.
AdvancedWriting a response of your own
Subclass SEC Defense Rule in Blueprint and implement two events.
| Event | Do |
|---|---|
| Should Apply | Judge whether this response handles the hit and change nothing. The context carries the defender, the pawn's state tags, the hit, and the blow before anything reduced it. |
| Apply | Change what the hit is worth. Scale or zero Final Damage and add a tag saying what happened. |
Apply runs only after Should Apply agreed and the component found the cost affordable, so a response has no reason to re-check its own gate. Override Get Display Name for an editor row title that includes the values authored on the instance.
A parry that scales with a stat, a block that only answers heavy attacks, a resistance keyed to a boss phase: each is one Should Apply branch.
AdvancedCosts against a project's own resources
Can Afford Response Cost and Pay Response Cost on the component are the seam. The defaults read and drain the pawn's Vitals component; override both together for a project running its own pools.
The component asks Can Afford Response Cost while it works a hit out, so that override must change nothing: a response the pawn cannot pay for steps aside rather than answering. Pay Response Cost runs afterwards, on the authority, and reports how much came off.
A pawn that keeps its states somewhere other than an ability system overrides Get State Tags in the same way, and every tag gate reads from what it returns.
AlternativeA pawn wired through Event Any Damage
Call Resolve Defense and Apply Damage (Any Damage Event) instead. It takes the loose numbers Unreal's damage event hands over and works the blow's direction out from where the attacker is standing, so a directional response still has a bearing to measure against.
It takes the surviving damage off the health pool too, so nothing after it should subtract health again. Prefer the version in the quick start wherever a damage info exists, since that one carries the exact hit and the attack's own tags.
AlternativeRunning your own health pool
Call Resolve Incoming Damage on the component instead of the one-node version. It runs the responses and charges what they cost, then hands back the result without draining health or the extra damage channels. Subtract its Damage Applied from your own health variable and return the result unchanged, so the attacker still gets the tags.
To drive each step yourself, Evaluate Defense, Apply Defense Result and Fill Damage Result are the same act split three ways: work out the answer, charge the costs on the server, then stamp the decision into the damage report.
MultiplayerMultiplayer
Charging a cost and draining health both need the authority, so run Resolve Defense and Apply Damage on the server. A call anywhere else charges nothing and drains nothing, and the result it hands back is advisory.
Preview Incoming Damage reaches the same answer on any machine, so a guard meter or a damage-preview widget on the owning client can call it freely.
Vitals replicate on their own, so the client sees the stamina a block spent without any extra wiring. See Vitals.
Related
| Page | Why |
|---|---|
| Attack Telegraphs | How an enemy learns a blow is coming in time to raise the guard these responses price. |
| Reaction System | The other half of a defence: the reaction plays the parry, the response decides what it was worth. |
| Melee Trace | Where the hit comes from, Skip Record Tags, Pass Through Tags, and the damage type vocabulary. |
| Vitals | The pools a costed response charges, and the health a resolved hit comes off. |
| Weapons | Weapon Defense Set, and arming an enemy so it arrives. |
| Animation Integration | Montage windows that hold a state tag for exactly the frames a response should answer on. |