# Build Your First Combo

> Build a sword with a three-hit combo from two assets of your own, an action graph and an item, and the demo's animation, mesh and keys. The demo's Item_UPC_Sword is the finished version.

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

## Set it up (15 minutes)

1. **Create the graph and its three hits**

   Create the asset: right-click in the Content Browser, choose **UPC > Actions > Action Graph**, and name it **AG_MySword**.

   *Right-click in the Content Browser, UPC, Actions, Action Graph.*

   Open it: **ROOT** is the character standing idle. Right-click the canvas, **Add Action Node**, three times, and set each card's **Node Name**, then the **Montage** and **Section Name** of its **Play Montage** payload, the part of the card that plays the move:

   | Node Name | Montage | Section Name |
   | --- | --- | --- |
   | `Light 1` | `AM_UPC_Sword_Combo` | `0` |
   | `Light 2` | `AM_UPC_Sword_Combo` | `1` |
   | `Light 3` | `AM_UPC_Sword_Combo` | `2` |

   Tick **Show Plugin Content** in the picker's view options to list it.
2. **Wire the hits into a chain**

   Drag from **ROOT**'s right edge to **Light 1**. On the router that appears (the small card on the wire, one row per input it takes), set the entry's **Input Tag** to `UPC.Input.LightAttack` (**Fires On**: **Input Pressed**). Wire **Light 1** to **Light 2** and **Light 2** to **Light 3** the same way, then **Compile** and save.

   Graph nodes:

   - **ROOT**
   - **Light 1** (montage AM_UPC_Sword_Combo)
   - **Light 2** (montage AM_UPC_Sword_Combo)
   - **Light 3** (montage AM_UPC_Sword_Combo)

   Connections:

   - ROOT to Light 1, through UPC.Input.LightAttack (pressed)
   - Light 1 to Light 2, through UPC.Input.LightAttack (pressed)
   - Light 2 to Light 3, through UPC.Input.LightAttack (pressed)

   *Three cards, each playing one section of the same montage, and a light attack press leading from each to the next. Nothing leads on from Light 3, so the character returns to ROOT when it ends.*
3. **Create the item**

   Create the asset: right-click in the Content Browser, choose **UPC > Items > Item Definition**, and name it **Item_MySword**.

   *Right-click in the Content Browser, UPC, Items, Item Definition.*

   Open `Item_MySword` and set **Slot Tags** to `UPC.Slot.Weapon.Sword`, so the demo belt's weapon slot takes it. Under **Fragments**, press **+**, pick **Visuals** and set **Mesh** to `SM_UPC_Sword`.
4. **Make it drawable, with its moves and its key**

   Add an **Equippable** fragment and fill it in as below, adding one **Input Mappings** row for the key. Give the **Hold Places** row `UPC.Place.Main` (the right hand) the demo sword's grip: **Offset** **Location** `-9.86`, `2.70`, `-0.45`, **Rotation** Y `-90`.

   In **Item_MySword**, under Fragments, set:

   | Property | Value |
   | --- | --- |
   | Index [ 1 ] | Equippable (replaces None) |
   | Index [ 1 ] > Action Graph | AG_MySword |
   | Index [ 1 ] > Input Mapping Context | IMC_UPC_Sword |
   | Index [ 1 ] > Input Mappings > Input Action | IA_UPC_LightAttack |
   | Index [ 1 ] > Input Mappings > Input Tag | UPC.Input.LightAttack (replaces None) |

   *Drawing the item adds its keys and graph; putting it away takes both back.*
5. **Give the blade a hit volume**

   Add a **Trace Sockets** row. Its sockets read `TraceStart` and `TraceEnd`, on `SM_UPC_Sword`'s guard and tip.

   In **Item_MySword**, under Trace Sockets, set:

   | Property | Value |
   | --- | --- |
   | ID | Blade (replaces None) |
   | Source Component Tag | UPC.ItemMesh (replaces None) |
   | Shape | Capsule Two Point (replaces Sphere) |

   *A capsule from TraceStart to TraceEnd, swept while a trace window plays.*

   The **ID** must read `Blade`, the name each trace window sweeps; `UPC.ItemMesh` tags the item's mesh in the hand.
6. **Put it in the hands and swing**

   Add `Item_MySword` to **Starting Items** on the **InventoryComponent** of `BP_UPC_Character` (`Demo/Characters/Player`), or of your copy once it is the game mode's Default Pawn Class (see Getting Started). Play `LVL_UPC_Demo`: the belt draws the sword from slot 1. At a training dummy, click to swing Light 1, then click during Light 1 and again during Light 2: each plays the next hit as that swing ends.

---

## When the blade hits

Each section of `AM_UPC_Sword_Combo` carries a **UPC Melee Trace Window** naming `Blade`, the only stretch where the blade hits.

**Timeline: AM_UPC_Sword_Combo** (2 s long). Tracks:

- **Sections**: 0 (0 s to 0.5626 s); 1 (0.5626 s to 1.137 s); 2 (1.137 s to 2 s)
- **Trace**: Melee Trace: Blade (0.3749 s to 0.5271 s); Melee Trace: Blade (0.8377 s to 1.087 s); Melee Trace: Blade (1.3464 s to 1.658 s)

---

## How the hits chain

**Within the combo.** With no **UPC Action Window** on the montage, a click during a swing waits for the section's end, then plays the next hit (**When No Window Is Authored**: **At Completion**). A UPC Action Window lets a click cut in sooner ([Action Graph](https://rigbak.com/docs/universal-player-combat/action-graph#mark-the-window-on-the-montage)).

**Restarting.** Light 3 has no next move, so a click restarts through ROOT only in Light 3's last 0.35 seconds: a click 0.2 seconds before the end restarts the combo, one 0.5 seconds before is forgotten. That limit is the graph's **Held Input Restart Window** (select empty canvas in the graph editor), and it applies to any waiting press.

---

## Use your own animations

1. **Make a montage**: right-click the animation, **Create**, **Create AnimMontage**. One per hit, or one with an unlinked section per hit, as the demo does.
2. **Make a damage config**: **UPC**, **Damage and Defense**, **Damage Config**. Its **Damage** starts at 10.
3. **Add a trace window to each swing**: **Add Notify State...**, **UPC Melee Trace Window**, across the frames where the blade connects, with **Socket IDs** `Blade` and your **Damage Config**.
4. **Point each node** at its **Montage** and **Section Name**.

See [Melee Trace](https://rigbak.com/docs/universal-player-combat/melee-trace) and [Damage and Hit Effects](https://rigbak.com/docs/universal-player-combat/damage-and-hit-effects).

## Use your own mesh

In your sword's static mesh, add the sockets `TraceStart` above the guard and `TraceEnd` at the tip (**Socket Manager**). [Equipment](https://rigbak.com/docs/universal-player-combat/equipment#where-an-item-is-held-hold-places) shows how to find the grip **Offset**.

---

<details>
<summary>The demo sword</summary>

| Demo asset | Adds |
| --- | --- |
| `AG_UPC_Sword` | Two heavy attacks, a guard that cuts in from any hit, a 0.25 second **Recovery** after a hit with no press waiting, and the shield's moves while a shield is drawn. Aliases wire the heavy and the guard to all three hits ([Action Graph Editor](https://rigbak.com/docs/universal-player-combat/action-graph-editor)). |
| `Item_UPC_Sword` | **Stowable** (it hangs on the back when put away), **Guard** (block and parry), **Swing Trail**, and the **Item Actor Class** `BP_UPC_Sword`, whose mesh tag `WeaponMesh` its Trace Sockets row names. |
| [Patterns](https://rigbak.com/docs/universal-player-combat/patterns) walks through the parry, the guard and the demo's other moves. |  |

</details>

---

## Debug it

```
UPC.Debug.Actions 1            // Each character's node, window and waiting press
UPC.Debug.Melee.DrawTracing 1  // The swept shapes, drawn in the world
```

<details>
<summary>Grant a graph or an item from code (C++)</summary>

- `UUPCInventoryComponent::AddItemDefinition(UUPCItemDefinition*, int32 StackCount = 1)` adds an item on the server; the belt takes it as it takes Starting Items.
- `UUPCEquipmentManagerComponent::EquipItem(UUPCItemDefinition*, UUPCInventoryItemInstance* = nullptr)` draws an item on the server, with no belt.
- `UUPCActionGraphComponent::SetActionGraph(UUPCActionGraphAsset*)` hands a character a graph with no item, for a creature whose moves never change.

</details>

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

**The sword swings, or not, and nothing is hit**

- **No sword in the hand:** the item lacks an Equippable fragment, the belt has no slot whose **Filter** its **Slot Tags** match, or **Starting Items** does not list it.
- **The press does nothing:** the Input Mapping's **Input Tag** differs from the transition's, the **Input Mapping Context** lacks the Input Action, or the graph is not compiled. `UPC.Debug.Actions 1` shows ROOT.
- **The swing hits nothing:** no volume named `Blade` registered. The row's ID differs, its **Source Component Tag** names a component nothing carries, the mesh lacks `TraceStart` or `TraceEnd`, or the sword sits in a place other than the first of its **Hold Places**, which registers `Blade_Off`. The Output Log names a refused row.

</details>

---

Previous page: [Getting Started](https://rigbak.com/docs/universal-player-combat/getting-started). Next page: [Character Setup](https://rigbak.com/docs/universal-player-combat/character-setup)
