Damage and Hit Effects
Documentation Unreal Engine Player Combat Damage Combat
What an attack is worth and what a landed hit does: the damage config, how a character takes a hit, impact cues by surface, hit stop, and a swing that bites on impact.
Set it up
2 minutes- 1
Open the damage config
OpenDamage_MySwordfrom the Melee Trace quick start, whose trace window already names it, and set Damage to 25.Damage_MySword▾DamageDamage10.0The health a hit takes before the target's defense. Damage Tags already holds UPC.DamageType.Slash. Starting on this page instead, create one (right-click in the Content Browser, UPC, Damage and Defense, Damage Config), addUPC.DamageType.Slashto its Damage Tags, and set it as Damage Config on the attack's UPC Melee Trace Window. - 2
Add an impact cue
A gameplay cue is a tagged one-shot effect, particles and a sound, that Unreal's ability system plays where the blow landed. Press + on Hit Effects, pick UPC Play Gameplay Cues, and add the demo's slash impact to its Attacker Cues. Attacker Cues fire through the attacker's ability system and suit the swing's own feedback (sparks, a sound); they are the only list that works for a struck wall or prop. Target Cues fire through the struck character's and attach to its body, for what the hit does to it. Both land at the impact point.Damage_MySword▾Hit Effects > Index [ 0 ]Attacker Cues0 Array elementsA cue on the attacker plays the moment the swing connects. - 3
Play, and hit something
Strike an enemy built on the UPC Character Base, such as the demo's: it loses 25 health and the slash impact plays.
Damage per attack
Details
Damage Config
Damage
Damage
25
Additional Vital Damage
0 Array elements
Damage Type Class
None
Damage Tags
1 Gameplay Tag
UPC.DamageType.Slash
Multi Hit Interval
-1
Max Targets Per Swing Override
-1
Use Authored Hit Direction
Hit Effects
Hit Effects1 Array element
Hit Effects
1 Array element
Index [ 0 ]UPC Play Gameplay Cues
Index [ 0 ]
UPC Play Gameplay Cues
One attack's damage, tags and hit effects. Name it on the attack's trace window, or as the trace component's Default Damage Config.
- A window's damage comes from the notify's Damage Config, else the trace's Default Damage Config, else its Base Damage (10).
- Damage Tags name the kind of damage (
UPC.DamageType.SlashandUPC.DamageType.Bluntship) and anything else a target reacts to, such as an unblockable swing. Defense responses read them; a parent tag covers every kind beneath it. - Additional Vital Damage drains other pools, one row each: 10 off stance while Damage takes 50 off health. A target with no such pool ignores the row.
How a character takes a hit
A character built on the UPC Character Base takes hits with nothing authored. On each hit:
- Its UPC Defense component works out what the blow is worth: a block or armor can shrink it (Defense).
- What gets through comes off the pool its Health Vital Tag names,
UPC.Vital.Health, a pool of 100 at the start (Vitals). - On Damage Taken runs.
Override On Damage Taken in the character Blueprint for a flinch, a death or a gameplay event; its Result carries Was Fatal, true on the hit that emptied health. A character with Can be Damaged off takes nothing. An actor not built on the base takes hits once it implements UPC Damageable (Character Setup).
AdvancedAnswering a hit your own way
- The character answers through Handle Incoming Damage on UPC Damageable, a function graph. Override it, call Resolve Incoming Hit for the standard answer, and return the damage that landed with tags saying what happened; the attacker's trace reads them to decide whether the swing is spent.
- Do not destroy the character inside Handle Incoming Damage: the attacker loses its cues and its push. Call Set Life Span, or destroy it on the next tick.
- An actor without the interface takes Unreal's point damage, carrying the config's Damage Type Class; leave that unset unless such a target reads it.
What a landed hit does
Add a row to the config's Hit Effects for each thing the attack does.
| Effect | Does |
|---|---|
| UPC Play Gameplay Cues | Cues on the attacker and the target: sparks, blood, sounds, decals. |
| UPC Apply Physics Impulse | Shoves the struck body: the limb, the whole body, or a tumble. |
| UPC Apply Gameplay Effect | A gameplay effect: an Unreal asset that adds tags or changes a value for a time. |
| UPC Hit Stop | Holds both characters' pose for a moment (Hit stop). |
| UPC Send Gameplay Event | An event an ability answers: a flinch, a parried attacker's recoil (Hit Reactions). |
| UPC Impact Slow | Slows the swing as it strikes a wall or heavy armor (Make a swing bite). |
| UPC Play Physical Reaction | Moves the struck character's bones under physics (Physical Reactions). |
| UPC Refill Vital | Fills one pool, such as poise on the hit that breaks it. |
Affected Sides picks who a row reaches: the attacker, the target, or both. Impulse and Physical Reaction reach the target only, Impact Slow the attacker only. Three checkboxes pick which hits run it: Run on Damageable Hits (a live target), Run on Inert Hits (a pawn with Can be Damaged off, such as a corpse) and Run on Scenery Hits (a wall). A new row runs on live targets only; UPC Impact Slow starts on corpses and walls.
Give a cue effect a Surface Set (a UPC Impact Surface Set asset mapping physical materials or surface types to surface names) to play a variant per surface struck; it needs a gameplay tag by the finished name. With
Damage_UPC_Sword (cue GameplayCue.UPC.Hit.Slash, set ImpactSurfaces_UPC_Default):| Struck material | Cue played |
|---|---|
PM_UPC_DefaultFlesh, which the set maps to Flesh | GameplayCue.UPC.Hit.Slash.Flesh |
| A material the set does not list, or a finished tag that does not exist | GameplayCue.UPC.Hit.Slash, as authored |
AdvancedGate an effect on the outcome
| Setting | Runs the effect |
|---|---|
| Suppress on Result Tags, Require Any Result Tags | Except, or only, for what the target reported: a parry's own sparks. |
| Require Any Target Tags, Suppress on Target Tags | Only, or except, while the target holds a tag as the hit lands, such as a stagger. |
| Require Damage Applied | Only when health came off. |
- A cue receives the impact point and normal, the surface, the damage, a fatal flag and what the target reported, so one cue notify can branch a parried hit.
- A Surface Set matches the struck physical material first, then its surface type.
Hit stop
Add UPC Hit Stop to the attack's Hit Effects and tick both sides under Affected Sides. It holds each character's drawn pose for Hold Seconds (0.05), longer on a killing blow, while the montage and movement run on underneath, so a combo keeps its timing. Each held character needs the UPC Hit Stop node in its Animation Blueprint (Animation Integration).
Details
UPC Hit Stop
Hit Stop
Hold Seconds
0.05
Fatal Hold Multiplier
1.5
Surface Scaling
None
Holds the drawn pose of the characters ticked under Affected Sides. Each needs a UPC Hit Stop node in its Animation Blueprint.
AdvancedHold length and surfaces
- Fatal Hold Multiplier (1.5) lengthens the hold on a killing blow.
- Surface Scaling on Density scales the hold by the struck material's density through Density Hold Curve; on Surface Type it reads Surface Hold Multipliers; None holds every surface alike.
- A hit landing during a hold extends it, up to Max Hit Stop Seconds (0.3), the project cap Animation Integration covers with Hit Stop Enabled.
Make a swing bite
Add UPC Impact Slow to the attack's Hit Effects: a swing striking a wall slows to Relative Rate (0.4 of its speed) for Duration (0.12 s) or until the attack ends, and the next attack follows a little later. For heavy armor, tick Run on Damageable Hits and put the armor's tag in Require Any Target Tags.
Details
UPC Impact Slow
Impact Slow
Relative Rate
0.40
Duration
0.12
Hit Effect
Run on Damageable Hits
Run on Inert Hits
Run on Scenery Hits
Slows the attacker's swing after its first qualifying contact. Answers walls, props and bodies taking nothing by default.
Impact Slow slows swings an action graph node plays; another ability's swing plays at full speed, and the log names it once. A montage with a time stretch curve cannot slow, and the action graph reports it on save.
Debug it
LogUPCDamage names an effect missing its tag or its gameplay effect. Saving a damage config reports an empty Hit Effects row, a side an effect cannot reach, and a hit stop past Max Hit Stop Seconds.
AdvancedWhere the blow came from
Each hit carries the bearing from attacker to target, which a directional guard or a reaction reads. Is Hit Direction Within Arc answers whether it arrived inside a front arc of a given half angle, a missing direction counting as frontal; Get Hit Direction Quadrant buckets it into Front, Back, Left or Right, and Get Hit Direction Angle Degrees gives the signed angle.
Tick Use Authored Hit Direction on the damage config to send a fixed direction, Authored Hit Direction Local, in the attacker's local space:
(0,0,1) launches the target up. The physics impulse follows it.AdvancedWhen Impact Slow runs
The slow starts at contact, before the target answers, so the asset reports an error when Suppress on Result Tags, Require Any Result Tags or Require Damage Applied is set on it; slow a parried or blocked attacker in its recoil reaction instead. Only an attack's first qualifying contact slows it, and the slow ends with that attack.
AlternativeDriving damage yourself
Damage Application on UPC Melee Trace picks what a landed hit does: Damageable Interface (default) asks the target through UPC Damageable and falls back to Unreal's point damage; Point Damage sends point damage for a project handling Event Any Damage; None sends nothing, and you bind On Melee Hit (the hit, the socket, the window's damage config and the kind of contact).
AlternativeThe same pipeline for a projectile or an explosion
UPC Damage Statics opens the same path to any other source, so an arrow and a sword resolve alike. UPC Deal Damage asks the target through UPC Damageable, falling back to point damage; UPC Deal Point Damage sends point damage; Classify Damage Target sorts a hit as the sweep does; Run Hit Effects runs a config's effects once the outcome is known. The deal nodes apply damage on the server and report an empty result elsewhere.
MultiplayerWhat runs where
- On Damage Taken runs on the server alone. Replicate what it starts, or start it from a gameplay cue.
- Can Play Ahead decides whether the attacking player's machine plays an effect at contact: true unless the effect waits on the target's answer (a result gate, Require Damage Applied). A waiting effect reaches the attacker a moment later, so a parried blow shows its impact at contact and the parry spark after. UPC Apply Gameplay Effect and UPC Send Gameplay Event run on the server alone (Hit Reactions covers the event's timing).
- UPC Play Gameplay Cues plays attacker cues at contact, without the damage figure or fatal flag; target cues fire from the server with its damage. Untick Allow Predicted to play every cue from the server.
- Unreal sends a character two gameplay cue calls per network update at most. A cue past that waits for the next update, and goes unsent after a quarter of a second without room. A cue your code plays in its own
FScopedGameplayCueSendContext, or one on an ability system replicating through a replication proxy, skips the wait; for those, raisenet.MaxRPCPerNetUpdateunder[ConsoleVariables]inConfig/DefaultEngine.ini. - Hit stop: a dedicated server holds nothing, a listen server only its own player's character. The attacker's machine holds at contact for the ordinary length, before it knows whether the blow killed; other machines play the server's hold with the fatal multiplier. A trace window ending during a hold sweeps on until the pose is back, at most twice Max Hit Stop Seconds.
- Impact Slow: the attacker's machine slows at contact, and the server slows its own copy, the one other players see, when the report arrives, even for a hit its checks refuse. Each judges the contact by its own view, so give armor its target tag through a gameplay effect, which both see. A report arriving after the server's swing ended slows the attacker's machine alone.
C++Extending hit effects
- A hit effect subclasses
UUPCHitEffect, in Blueprint or C++, and overrides On Hit. Should Run applies the gates first; Get Permitted Sides and Get Side Actor name the characters it may touch on this machine. UUPCDamageStatics::RunHitEffectListruns a list for one hit with anFUPCHitEffectContext, whose Source Ability is the ability whose swing struck.- An ability other than an action graph node takes an Impact Slow by implementing
IUPCImpactSlowReceiver. - A component implementing
IUPCPhysicsImpulseReceiveron the struck actor takes UPC Apply Physics Impulse's push in place of the default. - To Damage Definition on a damage config builds the damage a target receives.
AdvancedTroubleshooting
An effect does not play
| Check | Fix |
|---|---|
| The kind of hit, or a gate | Compare Run on Inert Hits, Run on Scenery Hits and the outcome gates with the hit. |
| The side | A cue effect plays Attacker Cues only with Attacker ticked, Target Cues only with Target ticked. |
| The surface variant | Create the tag the finished name makes, such as GameplayCue.UPC.Hit.Slash.Flesh. |
| The demo cues | They load, and go into a packaged game, while Load Demo Hit Effects is ticked (Project Settings, Plugins, Universal Player Combat Demo); a change applies on the next start. |
| A hold | It needs the UPC Hit Stop node, Hit Stop Enabled and Max Hit Stop Seconds above 0. |