Combat Styles

Documentation Unreal Engine Player Combat Combat Styles

A Combat Style is one asset that sets a character's combat feel: how the body turns, which enemies it picks, how far attacks travel, how the camera follows.


Set it up

5 minutes
  1. 1

    Create a style that turns attacks to the aim

    Start from a character that already attacks from its action graph, such as the demo character or the one from Build Your First Combo. Right-click in the Content Browser, UPC > Targeting > Combat Style, and name it CombatStyle_MyStyle. Open it, add a Rotation entry to Fragments and set Attack Facing to Aim.
    CombatStyle_MyStyle
    ▾Fragments, Index [ 0 ]: Rotation
    Rotation Mode 
    Attack FacingNone
    The body runs the way the stick points and turns to the camera's aim as each attack starts.
  2. 2

    Pick targets and keep attacks out of enemies

    Add a second fragment, Targeting. Set Targeting to the demo's TargetingConfig_UPC_OverShoulder and Steering to Distance Only.
    CombatStyle_MyStyle
    ▾Fragments, Index [ 1 ]: Targeting
    Targeting
    None▾
    SteeringToward Target
    Each attack travels as its animation does and stops short of enemies in its way.
  3. 3

    Give the style to the character

    In that character's Blueprint, select CombatComponent and set Style to CombatStyle_MyStyle.
    CombatComponent
    ▾UPC
    ▾Combat
    Style
    None▾
    A character not built on UPC Character Base needs three components from Add: UPC Combat, which holds the Style, and UPC Targeting and UPC Attack Approach, which the two fragments write to (What a style sets up).
  4. 4

    Press Play and attack sideways

    Place an enemy carrying UPC Targetable, such as a demo enemy. Run to the side and attack: the character turns to the camera's aim before it swings.

What a style sets up

Each fragment looks after one part of the character and puts back what it changed when the style goes. A part with no fragment keeps what the Blueprint sets: a style with only a Rotation fragment leaves the camera, targeting and keys alone.
FragmentSetsWorks through
RotationHow the body turns while fighting and while locked on, and which way an attack turns it as it starts.Character Movement; UPC Attack Approach for Attack Facing
TargetingWhich enemies the character picks, and how attacks steer at them.UPC Targeting; UPC Attack Approach for Steering
ApproachHow far short of a target an attack stops, how far it reaches, and how it turns and glides.UPC Attack Approach
MovementHow fast the character gets up to speed, stops and turns a run around.Character Movement; UPC Sprint for Sprint Blend Seconds
Gameplay TagsTags the character carries while the style is on, for a HUD, an ability or an animation to read.The character's ability system
Input MappingKey bindings that come and go with the style.The player's Enhanced Input
Camera RigThe camera's distance, offset and field of view, and its changes while a tag is on (Camera).UPC Camera Rig
Camera, Lock Follow, Camera, Frame BothHow the camera follows a locked target (Camera).The UPC Lock On Ability
UPC Character Base carries every component listed but UPC Sprint and UPC Camera Rig; the lock-on ability comes from an ability set (Targeting).

Switch styles during play

Call Set Style on the Combat component, on the server, with another style, or with none to hand every setting back; Get Combat Component finds the component on any actor. The old style's fragments revert before the new ones run, and On Style Changed fires with both styles.
BP_StylePlate · Event Graph
Event ActorBeginOverlap
Other Actor
Switch Has Authority
Authority
Remote
Get Combat Component
Actor
Return Value
Set Style
Target is UPCCombat Component
Target
New StyleCombatStyle_UPC_Freeflow
After adding, removing or swapping a UPC component on the character during play, call Reapply Style to run every fragment again against the components it has now.

Tags the character always carries

Character Tags on the Combat component, in the Blueprint or on one placed character, stay on the character whatever its style: its enemy type, its rank. A character not built on UPC Character Base needs one extra call, Notify Ability System Ready (UPC > Ability System), from Begin Play once its Ability System Component exists, so the tags can be applied. A transition's tag conditions and an ability's Activation Required Tags read them; Paired Actions uses them to give each enemy type its own animation for one shared action.

Fragment settings

Rotation: how the body turns

SettingDoes
Rotation ModeMovement Facing (default) faces the way the body moves, Camera Facing snaps to the camera's aim, Controller Desired turns toward the aim at Rotation Rate Yaw.
Rotation Rate YawTurn speed in degrees per second; 500 to start. Camera Facing ignores it.
Locked Rotation Mode, Locked Rotation Rate YawThe same two settings while a lock is held; Locked Rotation Rate Yaw starts at 700.
Attack FacingWhich way an attack turns the body as it starts: None (default), Aim, Movement or Lock Target. While a lock is held, every choice but None turns to the locked target (Attack Steering).

Targeting: who the character fights

SettingDoes
TargetingThe Targeting Config that picks and ranks targets. Empty: no target, no lock-on, and attacks neither steer nor stop short of enemies.
SteeringToward Target (default), Distance Only or Off; Attack Steering explains each. Under all three an attack stops short of enemies in its path.

Approach: how far an attack travels

This fragment sets the defaults on the UPC Attack Approach component, the part that moves the character. A window on the attack's montage (Attack Steering) overrides any value it sets but Make Room Seconds, and takes the default for the rest. The attack's own Play Montage node can set its Stop Distance and Make Room Seconds (Action Graph).
SettingDoes
Stop DistanceHow far short of a target an attack stops, in centimeters between the capsules; 150 to start. The attack's own Stop Distance, a window's Stop Distance Override and a weapon's Attack Stop Distance win over it.
Max Approach DistanceThe farthest target an attack closes on, in centimeters; 750 to start. Beyond it the attack only turns; 0 closes no gap.
Facing Interp Speed, Facing Speed by AngleHow fast an attack turns toward its target; the curve reads the angle still to turn.
Time Mapping CurveEasing for the glide; empty glides at a steady rate.
Speed Limit, Max Approach Speed, Moving Target, Lead StrengthHow fast a glide moves and how it follows a target that moves (Glides in detail).
Block Movement InputStops the stick moving the character while an attack closes in. Off to start.
Make Room SecondsAn attack starting closer than the stop distance to the enemy it aims at first steps straight back to the stop distance over this many seconds, and Keep Distance holds the swing there. That enemy is the target the attack steers at under Toward Target, else the targetable enemy deepest inside the stop distance that the facing line runs into. A wall or another body behind cuts the step short; the enemy never moves, and the body keeps its facing. 0, the default, turns it off. An attack's own Make Room Seconds on its Play Montage node takes over for that attack.

Movement: how fast it gets going

Tick a value to have the style set it; all four start ticked.
SettingDoes
Max AccelerationHow fast the character gains speed, in cm/s²; 4000 reaches a run in a stride, 512 in about a second.
Braking DecelerationHow fast it stops once the stick is let go, in cm/s²; 3000 to start.
Ground FrictionHow sharply it turns a run around; 12 to start.
Sprint Blend SecondsHow long the change to and from sprinting pace takes; it sets the UPC Sprint component's Speed Blend Seconds. 0.1 to start.

Tags and keys

Gameplay Tags puts its Tags on the character: the demo HUD shows its parts this way (HUD and Input Prompts), and UPC.State.BeltBlocked turns the belt off (Quick Bar).
Input Mapping adds its Input Mapping Context while the style is on. Of two contexts binding one key, the higher Priority wins: 10 here, 0 on an item's bindings, so the style's wins until you set it lower.

Debug it

Log LogUPCTargeting Verbose raises the style's log; Troubleshooting lists its warnings.
AdvancedWhen fragments run, and how they stack
  • Fragments run top to bottom and go back bottom to top. Of two fragments writing one setting, the lower one wins.
  • The style runs again as the character takes or lets go of a lock (Reason Lock Changed) and as its controller changes (Refreshed). Reapply Style and a new player taking the character over run it from the start (Applied).
  • The Rotation fragment reads the lock on each run, which switches to the locked rotation. The Targeting fragment and Attack Facing write only on the first run, so a runtime Set Targeting Config, Set Steering Mode or Set Attack Facing holds until the style changes or is reapplied.
  • Rotation, acceleration, braking and friction go on as overrides on the character's UPC Movement Modifiers, below an attack's facing hold. A node's Locomotion Modifier hook scales them, the new style's after a swap mid-attack.
  • Gameplay Tags and Character Tags keep a count: a tag another source also adds stays until both let go.
  • The first style is in force before Begin Play, so a listener bound there to On Style Changed reads Get Style once.
AdvancedA fragment of your own
Create a Blueprint class whose parent is UPCStyleFragment, override Apply and Revert, and add it to a style's Fragments like a built-in one.
  • Apply receives the character and a Context: Locked, Locked Target and Reason. It runs on every change above, so write what reads the Context on each run; write other values, and capture what you overwrite, only while Is Applied is false.
  • Revert puts back what Apply changed: when the style is cleared or swapped, before Reapply Style, when its Scope stops covering this machine, and when the Combat component leaves.
The three demo styles
The demo character starts on Over Shoulder; the style plates in LVL_UPC_Demo switch between the three. Each carries a UPC.Style tag and its HUD tags.
StyleSets
CombatStyle_UPC_OverShoulder, an aiming fightCamera Facing, also while locked; Attack Facing Aim. TargetingConfig_UPC_OverShoulder, Distance Only. Stop Distance 50, Max Approach Distance 250, Make Room Seconds 0.15. A close Camera Rig over the shoulder; Lock Follow with Min Pitch -35. IMC_UPC_OverShoulder: Execute on the lock key.
CombatStyle_UPC_Freeflow, brawling from enemy to enemyMovement Facing at 900 degrees per second; Movement at its defaults. TargetingConfig_UPC_Freeflow, Toward Target. Stop Distance 50, Max Approach Distance 400, Make Room Seconds 0.15, Block Movement Input. A Camera Rig pulling back while sprinting and engaged. UPC.State.SprintRequested (a run whenever the stick is pushed) and UPC.State.BeltBlocked. IMC_UPC_Freeflow: Guard, a counter in the unarmed graph, on the right mouse button; Execute on Left Ctrl.
CombatStyle_UPC_Soulslike, a deliberate fight around a lockMovement Facing, Controller Desired while locked; Attack Facing Movement. TargetingConfig_UPC_Soulslike, Steering Off. Make Room off. Lock Follow at its defaults.
MultiplayerScope: which machines a fragment sets up
Every fragment but the camera ones carries Scope. In single player all three run.
ScopeUse it for
Every MachineAnything gameplay reads: Rotation, Targeting, Approach, Movement. The default.
Locally Controlled OnlyWhat only the player at the controls sees: key bindings, HUD tags. Input Mapping starts here.
Authority OnlyWhat the server alone decides.
  • Style replicates; the fragments' values do not. The server turns, steers and stops attacks by its own values, and other machines stop an attack where the server does only under the same Steering and Targeting Config.
  • The player's machine predicts movement, so it needs the server's values; a style the server swaps in play reaches the player with a few corrections over about a round trip.
  • Gameplay Tags and Character Tags go on each machine from the asset, with nothing sent. A tag the server reads, such as UPC.State.BeltBlocked, needs Every Machine; one that comes and goes during play belongs on a Gameplay Effect.
  • Input Mapping does nothing on a dedicated server or for another player's character.
  • A new player taking the character over gets the style set up again, so a value set at runtime goes back to the style's; the same player retaking it keeps it.
C++C++
  • UUPCCombatComponent runs UUPCCombatStyleAsset::Fragments as per-character copies; FindFragment<T>() returns the character's own copy, which holds what it captured.
  • A fragment subclasses UUPCStyleFragment and overrides Apply_Implementation(AActor* Owner, const FUPCStyleContext& Context) and Revert_Implementation(AActor* Owner).
  • UUPCAbilitySystemReady::NotifyAbilitySystemReady calls SetUpForPlayer(const APlayerState*) and HoldCharacterTags(), which move CharacterTags onto the ability system the character answers now, as a controller change does. A pawn not built on the character base calls Notify Ability System Ready from C++ after each InitAbilityActorInfo when its ability system lives on the PlayerState.
AdvancedTroubleshooting
Warning saysFix
Set Style was called off the serverCall it on the server, behind Switch Has Authority.
... called from inside a style fragment's own Apply or RevertCall Set Style or Reapply Style from outside the fragment.
Rotation style fragment on ...: ... the character has noneGive the character a Character Movement component, or use Camera Facing.
... lists '...' twiceKeep one fragment of each class; only the second one's values go back.
... never puts it back in RevertGive your Blueprint fragment a Revert.
Validating a style warns on a Movement fragment off Every Machine and fails an Input Mapping fragment with no context.