Defense

Documentation Unreal Engine Combat Framework Defense Combat

Give enemies and the player a guard: author parries, blocks, invulnerability and armor as responses, lend them from a drawn item, tell the attacker what happened, and stagger an enemy or break a boss's posture with a parry.


Enemies and the player answer an incoming hit the same way: an ordered list of responses, where 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

3 minutes
  1. 1

    Find the Defense component

    Both character bases carry a UCF Defense component with no responses, so every hit lands whole until you author one. On an enemy built on Enemy Character Base or UCF Enemy Character Base it is named Defense; on a character built on the UCF character base, DefenseComponent. Both bases already route their hits through it.
    On any other pawn, press Add Component, pick UCF Defense, and answer its hits as Any other pawn shows.
  2. 2

    Create a Defense Rule Set

    Content Browser
    ▸ Content
    Right-click in the Content Browser, UCF, Damage and Defense, Defense Rule Set.
  3. 3

    Author a parry and a block

    Press + on Responses twice and pick UCF Guard both times. A Guard starts out as a block, so the first one, the parry, lets nothing through and costs nothing.
    DefenseRuleSet_MySword
    ▾Responses > Index [ 0 ] (UCF Guard)
    Damage Multiplier0.2
    Required Defender Tags 
    Result Tag 
    Cost Per Damage1.0
    Listed first, so a hit inside the parry window never reaches the block.
    DefenseRuleSet_MySword
    ▾Responses > Index [ 1 ] (UCF Guard)
    Required Defender Tags 
    Result Tag 
    The rest of a Guard ships as a block: a 60 degree half arc and a 0.2 multiplier.
  4. 4

    Hand the set to whoever guards

    Open the item definition the guard belongs to, add a Guard fragment to its Fragments, and point its Defense Set at the asset. A player or an enemy holding the drawn item answers hits with these responses, and stops the moment the item is put away.
    Details
    Guard
    Guard
    Defense Set
    DefenseRuleSet_MySword
    The block, parry or other responses the item lends whoever holds it, authored in a Defense Rule Set.
    An enemy holds the same items the player draws, through its Loadout: see Enemy Weapons. A pawn that fights with no item takes the set on its Defense component's Defense Set instead.
  5. 5

    Hold the tags while the guard is up

    Nothing puts the defender tags on for you.
    • On the player, put UCF.State.Blocking in the Applied Tags of the action graph node that holds the guard raised, and lay a UCF State Tag Window holding UCF.State.Parrying across the parry frames of its montage.
    • On an enemy, put UCF.State.Blocking in the Add Tags of its block reaction and UCF.State.Parrying in those of its parry reaction. Each reaction holds its tags while it runs. For a window tighter than the whole reaction, hold the tag with a UCF State Tag Window on the reaction's montage instead.
  6. 6

    Play, and hit it with the guard up

    A fifth of the damage lands, and the attacker's swing comes back carrying UCF.DamageResult.Blocked. Inside the parry window nothing lands. Drop the guard and the same blow lands whole.
A response answers only while the pawn holds the tags in its Required Defender Tags. Until a reaction, an action graph node, an ability or a montage window holds one, the response sits inert and hits land at full damage.
A response only one pawn needs does not need an asset. Press + on the Defense component's own Responses and author it there, with the same fields. Those run after whatever the pawn carries lends and before its Defense Set.
A Defense component with nothing authored and no Defense Set reports the incoming damage unchanged, so it changes nothing until the first response exists.

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.
ResponseAnswers whenShips with
UCF InvulnerableThe pawn holds the tags. No arc, so it answers from every direction, and no cost.Damage fixed at 0
UCF Guard as a parryThe pawn holds the parry window's tag and the blow arrives inside the arc.Set Damage Multiplier to 0 and Cost Per Damage to 0
UCF Guard as a blockThe pawn holds the raised guard's tag and the blow arrives inside the arc.60 degree half arc, multiplier 0.2, cost per damage 1
UCF Scale DamageThe pawn holds its defender tags and the attack carries its attack tags, where an empty list passes. Scales a hit: double against a stance-broken enemy, half against a buffed one, less against armor that resists a kind of damage.Multiplier 1, Continue After Claim on
A parry and a block are the same response with different values, so list the parry above the block and a hit inside the parry window never reaches the block. UCF Scale Damage scales a hit rather than answering it, and reports no result tag unless you give it one, so a blow only it touched reads to the attacker as a clean hit.
Four responses show as Deprecated in the response picker. Author with what replaces each, in the table below.
Deprecated responseAuthor instead
UCF Parry (Deprecated)UCF Guard with Arc Half Angle Degrees at 90, Damage Multiplier and Cost Per Damage at 0, and the parried Result Tag.
UCF Block (Deprecated)UCF Guard, which ships as a block.
UCF Damage Modifier (Deprecated)UCF Scale Damage, which gates on Required Defender Tags the same way.
UCF Damage Type Resistance (Deprecated)UCF Scale Damage with the damage kind in Required Attack Tags.

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: the Add Tags of an enemy's reaction, held while the reaction runs; the Applied Tags of the action graph node that plays the player's guard; an ability that holds the tag while it runs; or a UCF State Tag Window on a montage, which holds a tag for the frames it covers.
That is the seam between the two halves of a defense. The move plays the animation and holds the tag; the response prices a hit that lands during it. An enemy's block reaction holding UCF.State.Blocking plus one block UCF Guard covers the whole move, and so does a player's guard node holding the same tag. Neither knows about the other beyond the tag they share.

Author a response

What a guard reads

UCF Guard adds two fields of its own.
FieldSets
Arc Half Angle DegreesHalf the width of the arc the blow must arrive inside, in degrees to either side of straight ahead. 60, the starting value, 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.
Damage MultiplierHow much of the hit still lands. 0 stops it completely, which is a parry; 0.2, the starting value, lets a fifth through as chip damage, which is a block; 1 changes nothing.
UCF Scale Damage has a Damage Multiplier too, with no upper limit: 2 doubles the hit, 0.5 halves it. UCF Invulnerable adds nothing; it takes the whole hit.

What every response carries

Every response carries these.
FieldSets
Required Defender TagsTags the pawn must all hold for this to answer, such as those the parry, guard, or dodge ability grants while it runs. Empty answers whatever the pawn is doing.
Blocked Defender TagsTags that stop this answering when the pawn holds any of them, such as a stagger. Empty stops nothing.
Result TagWhat to call this answer, reported to the attacker so its swing and its impact effects can react. Unset reports nothing, which suits armor that only shaves damage.
Required Attack TagsTags the incoming attack must all carry for this to answer, read off the attack's Damage Tags. Empty answers whatever the attack is. A parent tag covers everything beneath it, so UCF.Damage.Elemental answers fire, ice and lightning, and UCF.DamageType answers slash and blunt.
Blocked Attack TagsTags that stop this answering when the attack carries any of them. List UCF.Attack.Unblockable here on a guard and an attack carrying that tag falls through to whatever sits below.
Continue After ClaimKeep running the responses below this one after this one answers, so a resistance can shave what a block let through. Off on UCF Guard and UCF Invulnerable, as a parry wants, and on for UCF Scale Damage.
Cost Vital TagVital 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 CostUnits charged per hit, whatever the blow was worth. Ignored while Cost Vital Tag is unset.
Cost Per DamageExtra 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 UCF Guard ships with charges nothing until you point that field at a pool.
Spend Remainder when UnaffordableTake whatever the vital has left when it cannot cover the full charge. The answer is refused either way and the hit falls through to the responses below; this decides only whether the pool empties on the way, raising its depleted tag and firing its depleted event, for a guard meant to break on the blow it could not afford. Off by default.
Vital Damage MultipliersVitals this response treats differently from health. Empty and one Damage Multiplier covers every vital, 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 afterward, so Preview Incoming Damage can 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 UCF Invulnerable at the top of the list, and point Required Defender Tags at that tag.
Details
UCF Invulnerable
Defender Gates
Required Defender Tags
1 Gameplay Tag
UCF.State.Invulnerable
Blocked Defender Tags
0 Gameplay Tags
Result
Result Tag
UCF.DamageResult.Blocked
Defense Rule
Continue After Claim
Attack Gates
Required Attack Tags
0 Gameplay Tags
Blocked Attack Tags
0 Gameplay Tags
Cost
Cost Vital Tag
None
Flat Cost
0
Cost Per Damage
0
Spend Remainder when Unaffordable
Vital Damage
Vital Damage Multipliers
0 Array elements
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. UCF.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 UCF.State.Intangible in Pass Through Tags on the attacker's melee trace instead. That tag is already in the shipped list, so a UCF State Tag Window holding it across the roll is the whole setup. Reach for UCF 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 and put a UCF Guard above the block. A Guard starts out as a block, so set Damage Multiplier to 0 for a parry that lets nothing through, Cost Per Damage to 0 so it costs nothing, and Result Tag to UCF.DamageResult.Parried. Arc Half Angle Degrees at 60 keeps it to the front, 60 degrees to either side.
Details
UCF Guard
Guard
Arc Half Angle Degrees
60
Damage Multiplier
0.00
Defender Gates
Required Defender Tags
1 Gameplay Tag
UCF.State.Parrying
Blocked Defender Tags
0 Gameplay Tags
Result
Result Tag
UCF.DamageResult.Parried
Defense Rule
Continue After Claim
Attack Gates
Required Attack Tags
0 Gameplay Tags
Blocked Attack Tags
0 Gameplay Tags
Cost
Cost Vital Tag
None
Flat Cost
0
Cost Per Damage
0
Spend Remainder when Unaffordable
Vital Damage
Vital Damage Multipliers
0 Array elements
A Guard set up as a parry: nothing lands, nothing is charged, and it answers only while the parry 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, so 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 a second UCF Guard under the parry, and point Cost Vital Tag at the stamina pool. The arc and the multiplier stay at their starting values.
Details
UCF Guard
Guard
Arc Half Angle Degrees
60
Damage Multiplier
0.20
Defender Gates
Required Defender Tags
1 Gameplay Tag
UCF.State.Blocking
Blocked Defender Tags
1 Gameplay Tag
UCF.State.Staggered
Result
Result Tag
UCF.DamageResult.Blocked
Defense Rule
Continue After Claim
Attack Gates
Required Attack Tags
0 Gameplay Tags
Blocked Attack Tags
0 Gameplay Tags
Cost
Cost Vital Tag
UCF.Vital.Stamina
Flat Cost
5
Cost Per Damage
1
Spend Remainder when Unaffordable
Vital Damage
Vital Damage Multipliers
0 Array elements
A Guard set up as a block. 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.

Armor

Put a UCF Scale Damage at the bottom of the list and name the kind of damage it resists in Required Attack Tags.
Details
UCF Scale Damage
Scale
Damage Multiplier
0.60
Defender Gates
Required Defender Tags
0 Gameplay Tags
Blocked Defender Tags
0 Gameplay Tags
Result
Result Tag
None
Defense Rule
Continue After Claim
Attack Gates
Required Attack Tags
1 Gameplay Tag
UCF.DamageType.Slash
Blocked Attack Tags
0 Gameplay Tags
Cost
Cost Vital Tag
None
Flat Cost
0
Cost Per Damage
0
Spend Remainder when Unaffordable
Vital Damage
Vital Damage Multipliers
0 Array elements
Shaves 40 percent off slash damage and carries on down the list, so it trims whatever the guards above it let through.
FieldSets
Required Attack TagsWhich kind of damage this resists, matched against the attack's Damage Tags. A parent tag covers everything beneath it, so UCF.Damage.Physical resists slashing, piercing and bludgeoning at once, and UCF.DamageType resists slash and blunt. Leave it empty to scale every hit, which is flat armor.
Damage MultiplierHow much of the hit still lands. Starts at 1, which changes nothing.
Result TagLeave it unset for plain armor, which shaves the damage without telling the attacker anything.
This response 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 armor touched reports no result tag and reads to the attacker as a clean hit. Melee Trace and Damage covers the damage tags an attack carries and where it picks them.

Where the responses come from

Most situational firstA hit enters at the top
1
What the pawn carries
The Guard fragment on each drawn item, an enemy's and a player's alike
A supporting item such as a shield answers ahead of the weapon that drives the moves. A set stops answering the moment its item is put away.
2
Responses on the component
UCF 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
UCF 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 armor wants and a parry does not.
FieldSets
Defense SetA shareable list of responses, for armor 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.
ResponsesResponses authored on this pawn alone, running after whatever the pawn is carrying brings and before the Defense Set.
Details
UCF Defense
UCF
Defense
Defense Set
DefenseRuleSet_MyArmour
Responses
0 Array elements
Outcome Effects
0 Array elements
Both character bases carry it with no responses: named Defense on Enemy Character Base, DefenseComponent on the UCF character base. Responses run top down. What the pawn carries answers first (the Guard fragments of drawn items, an enemy's and a player's alike), 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, DefenseRuleSet_MyArmour from the armor example 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.

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 and Damage.
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. Every demo weapon's damage config gates its body impact on UCF.DamageResult.Blocked and UCF.DamageResult.Parried this way, so a blocked or parried hit plays only the guard's effect. A gated effect waits for the server's answer, so the attacker's own machine shows it about a round trip after contact, while the hit stop still plays at contact. A config that also sounds on scenery keeps a second, ungated entry for scenery alone, since scenery sends no answer.
Two families ship, one with each layer: UCF.Defense.Parry, UCF.Defense.Block, UCF.Defense.Dodge and UCF.Defense.Clash with the enemy layer, and UCF.DamageResult.Parried, UCF.DamageResult.Blocked and UCF.DamageResult.GuardBroken with the player layer. They are separate tags, so a reader listing one family does not hear the other; see Two answer families below. A tag of your own works the same way, and listing a parent covers everything beneath it.
Outcome on a defense result, and UCF Defense Outcome, the enum it holds, are deprecated: read Result Tags instead. UCF Parry (Deprecated), UCF Block (Deprecated) and UCF Invulnerable write an outcome; UCF Guard, UCF Scale Damage and the two other deprecated responses leave it at Unguarded, so a Blueprint branching on it reads a guarded hit as unguarded.
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.

What the pawn does about it

Outcome Effects on the Defense component, and on a Defense Rule Set, are what the pawn does beyond taking the damage: a spark or a screen shake, a counter window it grants itself, a stagger it sends back to whoever swung. These are the same effects an attack authors on its damage config, so each carries the same outcome gates and picks the sides it lands on.
Gate one on Require Any Result Tags and it answers a single outcome. A parry that opens a counter window is one row:
SettingValue
EffectUCF Apply Gameplay Effect
Require Any Result TagsThe parry's own Result Tag: UCF.DamageResult.Parried or UCF.Defense.Parry
Gameplay EffectThe effect holding the window open
Affected SidesTarget
They run once the damage is off the pawn's pools, so an effect reading Was Fatal or a drained pool sees what the hit did.
AdvancedWhere the consequences come from
The component gathers the list the way it gathers responses: whatever the pawn is carrying hands its own over, then the component's own list, then the Defense Set. A set that arrives twice, carried and assigned, counts once. Order carries no meaning here, because each consequence that passes its gates runs, while responses stop at the first one that claims the hit.
Run Outcome Effects is the call for a project that works the damage steps by hand instead of calling Resolve Defense and Apply Damage. Call it last, once health has come off.
The demo's sword set carries a row of this kind: a parry applies GE_UCF_CounterWindow, which holds UCF.State.CanCounter for half a second, for the counter that follows.

Any other pawn

A pawn built on neither character base answers through the UCF Damageable interface. Add it under Class Settings, implement Handle Incoming Damage as a function graph, and return what one node hands back. 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_MyPawn · UCF Damageable interface
Handle Incoming Damage
Damage Info
UCFDefense
Resolve Defense and Apply Damage
Target is UCF Defense Statics
Defense
Damage Info
Health Vital TagUCF.Vital.Health
Return Value
Return Node
Return Value
Wire the pawn's UCF Defense component into the Defense pin; left empty, the node lands the hit at full value with no responses. Set Health Vital Tag on the node to the pawn's health pool, UCF.Vital.Health in the tags the framework ships. The pin starts empty, and the pawn needs a UCF Vitals component carrying a row for that tag; without either one the node resolves the hit and drains nothing. See Vitals.

On an enemy

An enemy built on Enemy Character Base answers every hit with nothing authored. Its Defense component runs the responses, what survives comes off the pool Health Vital Tag names in Project Settings (Plugins > Universal Combat Framework Enemy > Vitals, UCF.Vital.Health by default), and the hit is reported to the enemy's perception before any of that, so an enemy whose Awareness Config turns on the damage sense notices whoever struck it. It starts no flinch or other reaction of its own. For one, override Handle Incoming Damage in the enemy Blueprint and call Resolve Enemy Damage, which resolves the hit the same way and also reports it to the enemy's reactions. See Reaction System.
UCF Enemy Character Base resolves every hit through Resolve Enemy Damage itself, so its reactions and its perception hear each hit once, and a hit that empties its health drops the body limp. A Blueprint override of Handle Incoming Damage keeps both by calling the parent.

An item that brings its own guard

An enemy on UCF Enemy Character Base holds the player's items through its UCF Equipment Manager, and every item it holds whose definition carries a Guard fragment lends its set, ahead of the enemy's own responses, exactly as on the player. See Enemy Weapons.
BP_UCF_EnemyCharacter starts holding Item_UCF_TwoHandedBaton, whose Guard fragment lends DefenseRuleSet_UCF_TwoHanded: a parry while the enemy holds UCF.State.Parrying and a block while it holds UCF.State.Blocking, reporting UCF.DamageResult.Parried and UCF.DamageResult.Blocked. Its block reaction plays the player's baton block, AM_UCF_TwoHanded_Block, whose opening frames hold UCF.State.Parrying, so an enemy that raises its guard as the blow arrives parries it, as a player does.

On the player: an item that guards

A character built on the UCF character base answers every hit with nothing authored: its DefenseComponent runs the responses, what survives comes off the pool its Health Vital Tag names (UCF.Vital.Health, in the class defaults), and On Damage Taken reports what landed. While Unreal's Can be Damaged is off, it refuses the hit before any response runs. Melee Trace and Damage covers that end.
A sword's parry, a shield's block, a gauntlet that turns aside arrows: each belongs to the item, not the character. The Guard fragment on an item definition names the Defense Rule Set it lends, and a character answers hits with that set for as long as the item stays drawn.
Every drawn item with a Guard fragment lends its set, and they answer ahead of the character's own Responses. A supporting item, such as a shield in the off hand, answers ahead of the weapon that drives the moves. The demo's Item_UCF_Sword lends DefenseRuleSet_UCF_Sword, its parry and block, whose block plays GameplayCue.UCF.Block.Sword, sparks and a metal clang. Item_UCF_TwoHandedBaton lends DefenseRuleSet_UCF_TwoHanded, whose block plays the wooden GameplayCue.UCF.Block, and the shield plays GameplayCue.UCF.Block.Shield. See Items.

Parries against enemies

A parry the player lands with the sword, the baton or the shield sends the attacker UCF.Event.ParryRecoil, through an outcome effect on DefenseRuleSet_UCF_Sword, DefenseRuleSet_UCF_TwoHanded and DefenseRuleSet_UCF_Shield. The attacker answers through an ability in its Starting Abilities.
The attackerAnswers withWhat happens
An ordinary enemyGA_UCF_ParryRecoilIt plays the recoil and its swing stops, so a perfect block staggers it. While the recoil plays, its AI starts nothing new.
A bossGA_UCF_BossPostureNo recoil. The parry takes Drain Per Parry off the boss's own UCF.Vital.Stance row; when the row runs out it sends UCF.Event.GuardBreak, which starts the ordinary stun, GA_UCF_Stun, a window to strike.
Every demo enemy carries GA_UCF_ParryRecoil, and the boss parent, BP_UCF_BossCharacter, carries GA_UCF_BossPosture in its place. The dual-sword boss carries 150 Stance and loses 30 a parry, so the fifth clean parry breaks its guard. Its Stance starts refilling only 2.5 seconds after its last drain, so the parries of one exchange add up. Tune how many parries break a boss with Drain Per Parry against the Stance row's maximum, and keep the row's Regen Delay Seconds long enough for one exchange.
An enemy built without either ability ignores the event: give it one triggered by UCF.Event.ParryRecoil that plays its own recoil. The shield parries for the first quarter second of its raise, so a perfect block with the shield recoils an ordinary enemy as the sword's parry does.

Guard after a run of hits

A fighter that raises its guard after the second blow reads better than one that guards at random. The UCF Defense component counts the hits that got through: Get Hits Taken answers how many blows took health within the last Within Seconds. A blow a guard or a parry answered takes no health, so it does not count.
Who guardsReads the count throughThen
An enemyA Hits Taken Gate in the Conditions of a reaction rule answering UCF.Stimulus.DamageTaken: Hits blows (2 by default) within Within Seconds (4 by default), the blow being answered includedThe rule's reaction raises the guard. Keep the rule's Chance and Min Interval for how often.
A character on the player layer run by a Behavior TreeGet Hits Taken on its Defense componentA Queue Input Sequence step pressing Guard with Min Hold Seconds and Max Hold Seconds, so the guard stays up for that long.
The demo's dual-sword boss uses the first row: two blows landed within 5 seconds, four times in five, raise its guard for 1.5 to 3 seconds through an Action Graph Combo (Hold a guard for a while). The guard cuts a light string but never a hyper-armored swing, and the player's blows on it play the sword's block: sparks and a metal clang.
ReactionSet_UCF_TwoHanded keeps the montage way as an example, switched off. Its Guard reaction plays AM_UCF_TwoHanded_Guard through the montage ability and loops the montage's Hold section for 1.5 to 3 seconds, set by Hold Section, Min Hold Seconds and Max Hold Seconds on the reaction's Montage Payload (Action System). Its Enabled box is unticked, and the rule DodgeOrGuardAfterHits (two blows within 4 seconds, Chance 0.5) links only that reaction, so the rule never answers and a second blow falls to the next rule: the block when it is ready, else the dodge. Tick Enabled on the Guard reaction to see the guard.
MultiplayerCounting on the server
Hits are counted where they are resolved, on the server, so another machine's Defense component counts none. A reaction or an AI reading the count runs on the server already. The component keeps the latest 16 hits.

One defense, both layers

Enemies and the player run the same component, the same responses and the same rule sets, so a set authored for one side answers on the other. What follows is true only because both layers share it.

Guard tags both layers hold

UCF.State.Blocking, UCF.State.Invulnerable, UCF.State.Intangible and UCF.State.Staggered are one tag each, whichever layer holds them, and so is UCF.Attack.Unblockable. An enemy's block reaction and a player's guard node both hold UCF.State.Blocking, so one UCF Guard gated on it answers on either, and one dodge window holding UCF.State.Intangible passes both sides' swings. Any other tag works as a defender gate on any pawn that holds it, UCF.State.Parrying and UCF.State.StanceBroken included.

What an enemy reads off the player's guard

An enemy's actions read the tags their target holds. Tag Score Multipliers on an action scales its score while the target holds a tag, and Requires Tags and Block Tags gate it on the tags the enemy, its target and the world hold. A player with the guard up holds UCF.State.Blocking, so an enemy can hold back a light combo against a raised guard and reach for one that breaks it. Seam Patterns walks through it on the combo enemy.

Two answer families

The answer tags a Result Tag names come in two families. The enemy layer ships UCF.Defense.Parry, UCF.Defense.Block, UCF.Defense.Dodge and UCF.Defense.Clash; the player layer ships UCF.DamageResult.Parried, UCF.DamageResult.Blocked and UCF.DamageResult.GuardBroken. They share no parent, so whatever reads answers hears only the family it lists: Skip Record Tags on an attacker's melee trace, and Suppress on Result Tags and Require Any Result Tags on a hit effect or an outcome effect.
The demo uses the player layer's family: every demo set, the ones the enemies' items lend included, reports UCF.DamageResult, and every demo damage config and hit reaction that reads an answer reads that family. Pick one family for a project and name it in every response's Result Tag, or list both wherever an answer is read. The examples on this page use the UCF.DamageResult family.

Two kinds of damage tag

The enemy layer's damage kinds sit under UCF.Damage: slashing, piercing and bludgeoning under UCF.Damage.Physical, fire, ice and lightning under UCF.Damage.Elemental. The player layer's sit under UCF.DamageType: UCF.DamageType.Slash and UCF.DamageType.Blunt. The ready-made configs in Core/Damage, such as Damage_UCF_Bludgeoning, name the UCF.Damage kinds; every demo weapon's config, the enemies' swings included, names the UCF.DamageType pair. A resistance answers only the kinds its Required Attack Tags name, and it asks for all of them at once, so armor meant for attacks of both kinds takes one UCF Scale Damage per root.

An enemy's swing and the player's guard

An enemy holding the baton swings the player's baton montages and deals the player's baton damage, Damage_UCF_TwoHanded, so its hits follow the player's rules: they drain the player's poise toward a flinch, and the player's guard and parry answer them as they answer another player's.
The Defense component asks the pawn for lent sets, then each of its components. On an enemy, the UCF Equipment Manager answers with the set each drawn item's Guard fragment lends, ahead of the enemy's own responses. A set lent twice runs once.

Debug it

Press Play and swing at the pawn with the tag held, then without it.
UCF.Debug.Melee.DrawTracing 1    // The attacker's sweep, so you can see the blow reach the pawn
Filter the Output Log to LogUCFDefense. 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 in its Additional Vital Damage. A character built on the UCF character base also warns as it begins play, under LogUCFDamage, when its Vitals component carries no row for its Health Vital Tag.
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 Defender Tags names a tag no ability, reaction, action graph node 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 UCF Damageable interface on the pawn, UCF Deal Damage falls back to Unreal's point damage and the Defense component never runs. A character built on the UCF character base or on Enemy Character Base implements it already.
  • Can be Damaged is off. A melee trace skips a pawn with Unreal's Can be Damaged switched off, and a character built on the UCF character base refuses every hit while it is off, so no response runs.
  • The blow came from outside the arc. A Guard measures the direction the hit arrived from against the pawn's real facing. A hit from behind falls through to whatever sits below.
  • The attack carries a tag the response turns away. A tag in Blocked Attack Tags, such as UCF.Attack.Unblockable, lets the blow past, and a Required Attack Tags entry the attack lacks keeps the response silent.
  • 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 vital damage
An attack can carry damage to vitals other than health. One Damage Multiplier covers every vital 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 vital its own rate: name the vital's tag and set how much of it still lands. 0 stops that vital, 1 passes it untouched, and above 1 raises it, which is how you author a block that costs extra stance.
The walk reports the health figure and the extra vital damage separately, so a project applying them by hand has each one. See Vitals.
AdvancedScaling a hit by what the pawn is
UCF Scale Damage with Required Defender Tags filled in scales the hit while the pawn holds those tags. It has no arc, and it multiplies the hit by Damage Multiplier: 2 doubles it, 0.5 halves it, 1 changes nothing.
It ships with Continue After Claim on and reports no result tag unless you give it one, so a hit that only this touched reads to the attacker as a clean hit and the swing is spent normally. Gate it on UCF.State.StanceBroken or UCF.State.Staggered for the window where a guard-broken character takes extra, or on a buff tag for a target that takes less.
Its multiplier applies to every vital the hit carries, so pair it with a Vital Damage Multipliers row when one vital should scale at its own rate.
AdvancedBringing responses in from somewhere other than a weapon
UCF Defense Set Provider covers the rest of the cases, and it is Blueprint-implementable from Class Settings. Implement Get Defense Sets on the pawn, or on any component of it, and return one entry per thing in force. The UCF Equipment Manager answers it already with the sets its drawn items' Guard fragments lend, on the player and on an enemy alike.
The component stores nothing. It asks the pawn and its components 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 UCF Defense Response in Blueprint and implement two events. Your response gets the same Required Defender Tags, Blocked Defender Tags, attack tags, cost and Result Tag fields as the ones that ship, and the component checks the tags and reports the Result Tag for it.
EventDo
Should ApplyJudge 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.
ApplyChange what the hit is worth: scale or zero Final Damage.
Should Apply runs only after the tag checks passed, and Apply only after Should Apply agreed and the component found the cost affordable, so a response has no reason to re-check its own gates.
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.
A response subclassed straight from UCF Defense Rule gets no defender tags or Result Tag from the component, so it checks its own tags in Should Apply and adds its own result tag in Apply. Get Display Name on UCF Defense Rule is deprecated and nothing in the framework calls it; the editor names a response by its class's display name.
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 afterward, on the authority, and reports how much came off. A response with Spend Remainder when Unaffordable ticked also asks Get Payable Response Cost how much the pool can still give, so override that one too.
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 Resolve Defense and Apply Damage 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 vitals. 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.
C++C++
TypeWhat it is
UUCFDefenseComponentUCF Defense. GetEffectiveResponses, GetEffectiveOutcomeEffects, GetStateTags, CanAffordResponseCost, GetPayableResponseCost and PayResponseCost are BlueprintNativeEvents to override.
UUCFDefenseResponseThe base for a new response: the walk checks its defender gates and reports its ResultTag. Override ShouldApply, Apply and GetVitalDamageMultiplier.
UUCFDefenseRuleThe class beneath UUCFDefenseResponse that the walk runs, open to Blueprint. A rule built straight on it checks its own defender tags and adds its own result tag.
UUCFDefenseRule_Guard, UUCFDefenseRule_Invulnerable, UUCFDefenseRule_ScaleThe responses that ship.
UUCFDefenseRule_Parry, UUCFDefenseRule_Block, UUCFDefenseRule_DamageModifier, UUCFDefenseRule_DamageTypeResistanceDeprecated, in Legacy/UCFDefenseRulesLegacy.h; EUCFDefenseOutcome is in Legacy/UCFDefenseOutcome.h.
UUCFDefenseRuleSetThe Defense Rule Set asset: Responses and OutcomeEffects.
IUCFDefenseSetProviderGetDefenseSets. AEnemyCharacterBase and UUCFEquipmentManagerComponent implement it.
UUCFItemFragment_GuardThe Guard fragment. The equipment manager's Get Defense Sets returns the drawn items' guards, supportive items first.
UUCFDefenseStaticsEvaluateDefense, ApplyDefenseResult, FillDamageResult, ApplyDamageResultToVitals, ResolveAndApplyIncomingDamage and ResolveAnyDamageEvent.