# Getting Started with Universal Player Combat

> Turn Universal Player Combat on, play the demo map and land a hit with a sword off the rack, then build on the demo player or remove the demo when you no longer need it.

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

## Set it up (5 minutes)

1. **Turn the plugin on**

   Get **Universal Player Combat** on Fab and click **Install to Engine** in the Epic Games Launcher (5.6, 5.7 or 5.8). In your project, open **Edit > Plugins**, tick it and restart. The engine plugins it needs switch on with it and its gameplay tags register themselves: no collision channels, surface types or tag files to set up.
2. **Open the demo map**

   Turn on **Show Plugin Content** in the Content Browser's settings, then open `Demo/Maps/LVL_UPC_Demo`.

   In **LVL_UPC_Demo**, under Game Mode, set:

   | Property | Value |
   | --- | --- |
   | GameMode Override | BP_UPC_GameMode |

   *Set in the demo map's World Settings. For a level of your own, set it there or as the Default GameMode in Project Settings > Maps & Modes.*
3. **Take a sword**

   Press Play and walk down the hallway to the **weapon rack** on your left. Look at a sword and press **E**: it goes on belt slot 1 and into your hand. **1** puts it away and draws it again.
4. **Hit a training dummy**

   The two **training dummies** stand on the right, a few steps back. The **left mouse button** is a light attack (click again during each swing for a three-hit combo), the **right** a heavy one. The dummies cannot die; the right one adds sparks and a short pause on each hit.

---

## Keys

| Action | Keyboard and mouse | Gamepad |
| --- | --- | --- |
| Move, look | W A S D, mouse | Left stick, right stick |
| Light attack | Left mouse button | Right shoulder |
| Heavy attack | Right mouse button | Right trigger |
| Guard: a sword parries on a press as the hit lands and blocks while held; a shield rises | Q | Left trigger |
| Lock on, then flick sideways to switch target | Middle mouse button, then the mouse | Top face button, then the right stick |
| Dash: a dodge with a weapon, a vault over an enemy with bare fists | Space | Left shoulder |
| Interact, and the second option (kick, break) | E, F | Bottom face button, left face button |
| Draw or put away a belt slot | 1 to 4 | D-pad |
| Drop what is in hand | G | Right face button |
| Open the inventory | I | Tap View |
| Sprint (hold) | Left Shift | Left stick click |
| Swap the camera shoulder | V | Right stick click |
| Jump to the start, the paired actions, the style plates | 7, 8, 9 | Hold the right special button, press the D-pad up, right, down |

On the **Freeflow** style plate (below), the right mouse button guards instead, and a guard on a punch showing the counter marker counters it.

---

## What the demo shows

| Stop | Try | Open |
| --- | --- | --- |
| **Door** | **E** opens it, **F** kicks it open | `BP_UPC_Door` |
| **Training dummies** | The right one has a defense set of its own | `BP_UPC_HitDummy`, `DefenseRuleSet_UPC_HitDummy` |
| **Chests** | **E** opens a chest, **F** breaks the lid off | `BP_UPC_Chest` |
| **Loot chest** | **E** opens your inventory beside it on a style that has a screen (switch at the wardrobe's style pads first), **F** takes everything that fits | `BP_UPC_LootChest` |
| **Places on the Body** | Two figures draw and sheathe two swords, and a sword and shield | `BP_UPC_EquipmentShowcase` |
| **Weapon rack** | **E** takes a sword or the shield, or puts a sword back on an empty peg | `BP_UPC_WeaponRack` |
| **Paired actions** | Six stations loop executions, counters and a vault; step onto the ring marked (you) and press **E** | `BP_UPC_PairedStation`, `Paired_UPC_*` |
| **Style plates** | **Over Shoulder** (sword and shield), **Freeflow** (bare fists), **Soulslike** (two swords), each with its arena; a red plate brings you back | `BP_UPC_StylePlate`, `Demo/Combat/Styles` |
| **Wardrobe** plate, in the start room | A pad for each weapon and worn item, and pads that switch the inventory style | `LVL_UPC_Wardrobe` |

<details>
<summary>The arenas</summary>

| Arena | Enemies | What it shows |
| --- | --- | --- |
| **Over Shoulder** | Three bosses with a two-handed baton, one attacking at a time | Block, parry, a shield bash, telegraphed swings |
| **Freeflow** | Four weaker enemies, two attacking at once | Strikes aimed with the stick, a dash strike at range, a counter on a punch showing the counter marker, a vault over an enemy |
| **Soulslike** | One boss with a two-handed baton, picking its swing by your distance. After 250 damage it stays stunned until you walk up and press Light Attack, and only that sword execution kills it | Lock-on, parry and block with two swords, a finisher |

The enemies are built on UPC Character Base and run action graphs pressed by a Behavior Tree: the Freeflow crowd uses the player's unarmed graph, the bosses the baton's. They take turns through an attack token pool per arena (`BP_UPC_AttackTokens`). [Patterns](https://rigbak.com/docs/universal-player-combat/patterns) walks through their moves.

</details>

---

## Build on the demo player

Duplicate `BP_UPC_Character` (`Demo/Characters/Player`) and swap its mesh and Animation Blueprint. The demo's moves fit the demo mannequin's skeleton, so another skeleton needs [animations of its own](https://rigbak.com/docs/universal-player-combat/first-combo#use-your-own-animations) and the Animation Blueprint needs the Slot nodes the montages play in ([The Animation Blueprint](https://rigbak.com/docs/universal-player-combat/character-setup#the-animation-blueprint)). A character with its own parent class follows [Character Setup](https://rigbak.com/docs/universal-player-combat/character-setup).

| Where | Setting | Value |
| --- | --- | --- |
| Class Defaults | **Starting Ability Set** | An asset listing abilities and their input bindings; the demo's `AbilitySet_UPC_Default` holds lock-on, interact, sprint, drop, item use, and the demo's hit reactions |
| Equipment Manager | **Default Item** | `Item_UPC_Unarmed`, the fists it fights with when nothing else is drawn |
| Equipment Manager | **Body Places** | Main hand `hand_r`, off hand `hand_l`, three sheaths on the back |
| Inventory | **Config** | `InventoryConfig_UPC_Simple`: it carries what the belt holds and the gear it wears, and opens no inventory screen; no Starting Items |
| Combat | **Style** | `CombatStyle_UPC_OverShoulder` |
| Targeting | **Targeting Config** | `TargetingConfig_UPC_OverShoulder` |
| Vitals | **Vitals** | Health, Stamina and Stance (a pool whose emptying staggers the character), each 100 and refilling 10 a second after 3 seconds ([Vitals](https://rigbak.com/docs/universal-player-combat/vitals)) |
| Team | **Team Id** | 0; the demo's enemies are on 1 |
| Mesh | **Component Tags** | `UPC.Montage`, `UPC.Attachment.Body` |

`BP_UPC_PlayerController`, a **UPC Player Controller**, carries the belt (a **UPC Quick Bar** of four slots that takes new items and draws them), the shared keys (`IMC_UPC_Default`), the HUD and the inventory screens. `BP_UPC_GameMode` names both classes. To play your duplicate, duplicate `BP_UPC_GameMode`, set its **Default Pawn Class** to your character, and set it as the level's **GameMode Override**.

The demo map's Level Blueprint (**Blueprints > Open Level Blueprint**) holds one comment box per system of unconnected example nodes to copy.

---

## Removing the demo (optional)

The `Demo` folder is optional. Keep it to learn from, or remove it once nothing of yours uses it. The plugin's **Core** folder holds everything it needs to run. With the plugin installed to the engine, every project on that engine shares the `Demo` folder, so leave it in place there.

1. Untick **Load Demo Hit Effects** in **Project Settings > Plugins > Universal Player Combat Demo**. It loads the demo's sparks, sounds and camera shakes; hit stop plays without it. It takes effect on the next start.
2. Right-click each of your assets built from the demo (your character, game mode, items and levels) and open the **Reference Viewer**: each asset it lists under `Demo` is one your asset still references. A duplicate of `BP_UPC_Character`, for one, still points at the demo assets in the table above, such as `AbilitySet_UPC_Default` and `Item_UPC_Unarmed`.
3. **Duplicate** each of those into your own folders and point your asset at the copy. A copy can point at demo assets of its own (your character, then its item, then the item's action graph, then the graph's montages), so repeat until the Reference Viewer shows nothing under `Demo`.
4. Last, delete the `Demo` folder.

---

## Debug it

```
UPC.Debug.All 1          // Every overlay above every character; UPC.Debug.All 0 clears them
UPC.Debug.Actions 1      // The node each character is in, its window, a press waiting
UPC.Debug.Equipment 1    // What each character holds, which item drives combat, what it carries
UPC.Debug.Targeting 1    // Who each character fights, and each candidate's score
UPC.Debug.Interaction 1  // What the character can use, and the option a press would run
UPC.Debug.Vitals 1       // Every pool against its maximum
UPC.Logs Verbose         // Every log category; UPC.Logs alone puts back warnings only
```

<details>
<summary>More debug switches (Advanced)</summary>

- `UPC.Debug.WatchPawn <name>` narrows every overlay to one character, part of a name being enough; `UPC.Debug.WatchClear` puts them all back.
- `UPC.Debug.MaxDistance` sets how far from the camera a character still draws (4000 cm), and `UPC.Debug.TextScale` sizes the text.
- `UPC.Debug.Melee.DrawTracing 1` draws every weapon sweep, and `UPC.Debug.Steering.Draw 1` where each attack steers.
- The plugin logs only warnings, each naming a setup mistake and its fix; `Log LogUPCInventory Verbose` raises one category.

</details>

<details>
<summary>What the demo player is made of (Advanced)</summary>

Components panel of **BP_UPC_Character**:

- Capsule Component (inherited)

  - Arrow Component (inherited)
  - Mesh (inherited)
  - SpringArm (add)

    - TPSCamera (add)
- Character Movement (inherited)
- Equipment Manager Component (inherited)
- Inventory Component (inherited)
- Action Graph Component (inherited)
- Melee Trace Component (inherited)
- Input Mapping Component (inherited)
- Anim Manager Component (inherited)
- Vitals Component (inherited)
- Defense Component (inherited)
- Targeting Component (inherited)
- Targetable Component (inherited)
- Team Component (inherited)
- Approach Component (inherited)
- Combat Component (inherited)
- Interactor Component (inherited)
- Anim Effect Component (inherited)
- Ability System Component (inherited)
- UPCSpeedModifier (add)
- UPCPhysicalReaction (add)
- UPCTelegraphViewer (add)
- MotionWarping (add)
- UPCStowVisual (add)
- UPCCameraRig (add)
- Sprint (add)

*Grayed rows come with the engine's Character and UPC Character Base; the rest is what the demo Blueprint adds.*

[Character Setup](https://rigbak.com/docs/universal-player-combat/character-setup) says what each of the base's components does. The base moves with **UPC Character Movement**, which keeps a player's corrections smooth under lag, and answers hits itself: its defenses resolve the hit and the rest comes off its health. Override **On Damage Taken** in a Blueprint child for a flinch or a death ([Damage and Hit Effects](https://rigbak.com/docs/universal-player-combat/damage-and-hit-effects#how-a-character-takes-a-hit)). Its Class Defaults:

| Setting | Default | Does |
| --- | --- | --- |
| **Starting Ability Set** | None | Abilities the character has from the start, bound to their keys on the player's machine. Weapon moves belong on the item. |
| **Draw Starting Items** | on | Draws the inventory's equippable items into the hands, unless the controller's belt has **Auto Populate from Inventory** on and takes them. |
| **Ignore Camera Collision** | on | Keeps a camera from zooming in when this character walks between it and the player it follows. |
| **Health Vital Tag** | `UPC.Vital.Health` | The pool a hit takes its damage off. |

Its Vitals start with a Health row of 100 and its Team Component on no team (255) until you set **Team Id**.

</details>

<details>
<summary>An ability system on the PlayerState (Multiplayer)</summary>

The demo keeps each character's ability system on the character, in Mixed replication mode. To keep a player's abilities across deaths and respawns, host it on the PlayerState:

1. Write a PlayerState in C++ that implements `IAbilitySystemInterface` and creates a replicated ability system component in **Mixed** replication mode. Raise its **Net Update Frequency** (100 works); the engine's default is low.
2. Set the game mode's **Player State Class** to it.

A character built on UPC Character Base uses a PlayerState's ability system in place of its own, granting its abilities on possession and taking them back when it ends. The PlayerState needs C++ because Blueprint cannot implement the interface. **Get Ability System Component Internal**, overridable in a Blueprint child of the base, points the character at an ability system kept elsewhere.

</details>

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

- `AUPCCharacterBase` (`UPCGame`) is `Abstract` and `Blueprintable`, derives from `ACharacter`, and implements `IAbilitySystemInterface` and `IUPCDamageable`.
- `InitializeAbilityActorInfo` (virtual, protected) runs from `PossessedBy` on the server and `OnRep_PlayerState` on clients: it calls `InitAbilityActorInfo(Owner, this)`, grants the Starting Ability Set and sends `UUPCAbilitySystemReady::NotifyAbilitySystemReady`. `NotifyControllerChanged` calls `RefreshAbilityActorInfo()`, which a PlayerState-hosted system needs since a client can receive the PlayerState before the controller.
- `GetAbilitySystemComponentInternal` (BlueprintNativeEvent) resolves the ability system, PlayerState first; `OnDamageTaken` (BlueprintNativeEvent, authority only) and `ResolveIncomingHit` are the damage seams.
- A C++ child that moves with a movement component of its own passes its class to the protected constructor `AUPCCharacterBase(const FObjectInitializer&, TSubclassOf<UCharacterMovementComponent>)`.
- `AUPCPlayerController` creates the `UUPCQuickBarComponent` and calls `InitializeForPawn` from `OnPossess` and `OnRep_Pawn`.

</details>

---

Previous page: [Universal Player Combat](https://rigbak.com/docs/UniversalPlayerCombatDocs). Next page: [Build Your First Combo](https://rigbak.com/docs/universal-player-combat/first-combo)
