# 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.

Markdown version of https://rigbak.com/docs/universal-player-combat/combat-styles, a page of the Universal Player Combat documentation. Link that page when citing it.

## Set it up (5 minutes)

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](https://rigbak.com/docs/universal-player-combat/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**.

   In **CombatStyle_MyStyle**, under Fragments, Index [ 0 ]: Rotation, set:

   | Property | Value |
   | --- | --- |
   | Rotation Mode | Movement Facing |
   | Attack Facing | Aim (replaces None) |

   *The body runs the way the stick points and turns to the camera's aim as each attack starts.*
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**.

   In **CombatStyle_MyStyle**, under Fragments, Index [ 1 ]: Targeting, set:

   | Property | Value |
   | --- | --- |
   | Targeting | TargetingConfig_UPC_OverShoulder |
   | Steering | Distance Only (replaces Toward Target) |

   *Each attack travels as its animation does and stops short of enemies in its way.*
3. **Give the style to the character**

   In that character's Blueprint, select **CombatComponent** and set **Style** to `CombatStyle_MyStyle`.

   In **CombatComponent**, under UPC > Combat, set:

   | Property | Value |
   | --- | --- |
   | Style | CombatStyle_MyStyle (replaces 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](https://rigbak.com/docs/universal-player-combat/combat-styles#what-a-style-sets-up)).
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.

| Fragment | Sets | Works through |
| --- | --- | --- |
| **Rotation** | How 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 |
| **Targeting** | Which enemies the character picks, and how attacks steer at them. | UPC Targeting; UPC Attack Approach for Steering |
| **Approach** | How far short of a target an attack stops, how far it reaches, and how it turns and glides. | UPC Attack Approach |
| **Movement** | How fast the character gets up to speed, stops and turns a run around. | Character Movement; UPC Sprint for Sprint Blend Seconds |
| **Gameplay Tags** | Tags the character carries while the style is on, for a HUD, an ability or an animation to read. | The character's ability system |
| **Input Mapping** | Key bindings that come and go with the style. | The player's Enhanced Input |
| **Camera Rig** | The camera's distance, offset and field of view, and its changes while a tag is on ([Camera](https://rigbak.com/docs/universal-player-combat/camera#set-the-cameras-distance-and-framing)). | UPC Camera Rig |
| **Camera, Lock Follow**, **Camera, Frame Both** | How the camera follows a locked target ([Camera](https://rigbak.com/docs/universal-player-combat/camera#the-camera-while-locked-on)). | 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](https://rigbak.com/docs/universal-player-combat/targeting#lock-on)).

---

## 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.

Blueprint graph, nodes in reading order:

- **Comment box: BP_StylePlate · Event Graph**

  - **Event ActorBeginOverlap** (event); outputs: Other Actor
  - **Switch Has Authority** (macro); outputs: Authority, Remote
  - **Get Combat Component** (pure function); inputs: Actor; outputs: Return Value
  - **Set Style** (function; Target is UPCCombat Component); inputs: Target, New Style = CombatStyle_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](https://rigbak.com/docs/universal-player-combat/paired-actions#one-action-a-different-animation-for-each-enemy-type) uses them to give each enemy type its own animation for one shared action.

---

## Fragment settings

### Rotation: how the body turns

| Setting | Does |
| --- | --- |
| **Rotation Mode** | **Movement 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 Yaw** | Turn speed in degrees per second; 500 to start. Camera Facing ignores it. |
| **Locked Rotation Mode**, **Locked Rotation Rate Yaw** | The same two settings while a lock is held; Locked Rotation Rate Yaw starts at 700. |
| **Attack Facing** | Which 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](https://rigbak.com/docs/universal-player-combat/attack-steering#turn-the-body-as-an-attack-starts)). |

### Targeting: who the character fights

| Setting | Does |
| --- | --- |
| **Targeting** | The [Targeting Config](https://rigbak.com/docs/universal-player-combat/targeting#the-targeting-config) that picks and ranks targets. Empty: no target, no lock-on, and attacks neither steer nor stop short of enemies. |
| **Steering** | **Toward Target** (default), **Distance Only** or **Off**; [Attack Steering](https://rigbak.com/docs/universal-player-combat/attack-steering#pick-how-attacks-steer) 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](https://rigbak.com/docs/universal-player-combat/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](https://rigbak.com/docs/universal-player-combat/action-graph#choose-what-a-node-plays)).

| Setting | Does |
| --- | --- |
| **Stop Distance** | How 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 Distance** | The 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 Angle** | How fast an attack turns toward its target; the curve reads the angle still to turn. |
| **Time Mapping Curve** | Easing for the glide; empty glides at a steady rate. |
| **Speed Limit**, **Max Approach Speed**, **Moving Target**, **Lead Strength** | How fast a glide moves and how it follows a target that moves ([Glides in detail](https://rigbak.com/docs/universal-player-combat/attack-steering#glides-in-detail)). |
| **Block Movement Input** | Stops the stick moving the character while an attack closes in. Off to start. |
| **Make Room Seconds** | An 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](https://rigbak.com/docs/universal-player-combat/attack-steering#keep-distance-stop-short-of-enemies) 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.

| Setting | Does |
| --- | --- |
| **Max Acceleration** | How fast the character gains speed, in cm/s²; 4000 reaches a run in a stride, 512 in about a second. |
| **Braking Deceleration** | How fast it stops once the stick is let go, in cm/s²; 3000 to start. |
| **Ground Friction** | How sharply it turns a run around; 12 to start. |
| **Sprint Blend Seconds** | How 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](https://rigbak.com/docs/universal-player-combat/hud-and-input-prompts#show-parts-of-the-hud-by-combat-style)), and `UPC.State.BeltBlocked` turns the belt off ([Quick Bar](https://rigbak.com/docs/universal-player-combat/quick-bar#a-combat-style-without-a-belt)).

**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.

<details>
<summary>When fragments run, and how they stack (Advanced)</summary>

- 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.

</details>

<details>
<summary>A fragment of your own (Advanced)</summary>

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.

</details>

<details>
<summary>The three demo styles</summary>

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.

| Style | Sets |
| --- | --- |
| `CombatStyle_UPC_OverShoulder`, an aiming fight | Camera 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 enemy | Movement 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 lock | Movement Facing, Controller Desired while locked; Attack Facing Movement. `TargetingConfig_UPC_Soulslike`, Steering Off. Make Room off. Lock Follow at its defaults. |

</details>

<details>
<summary>Scope: which machines a fragment sets up (Multiplayer)</summary>

Every fragment but the camera ones carries **Scope**. In single player all three run.

| Scope | Use it for |
| --- | --- |
| **Every Machine** | Anything gameplay reads: Rotation, Targeting, Approach, Movement. The default. |
| **Locally Controlled Only** | What only the player at the controls sees: key bindings, HUD tags. Input Mapping starts here. |
| **Authority Only** | What 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.

</details>

<details>
<summary>C++</summary>

- `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.

</details>

<details>
<summary>Troubleshooting (Advanced)</summary>

| Warning says | Fix |
| --- | --- |
| Set Style was called off the server | Call it on the server, behind **Switch Has Authority**. |
| ... called from inside a style fragment's own Apply or Revert | Call Set Style or Reapply Style from outside the fragment. |
| Rotation style fragment on ...: ... the character has none | Give the character a Character Movement component, or use Camera Facing. |
| ... lists '...' twice | Keep one fragment of each class; only the second one's values go back. |
| ... never puts it back in Revert | Give 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.

</details>

---

Previous page: [Inventory Rules and Combines in Blueprint](https://rigbak.com/docs/universal-player-combat/inventory-blueprint). Next page: [Targeting](https://rigbak.com/docs/universal-player-combat/targeting)
