Build Your First Combo
Documentation Unreal Engine Player Combat Tutorial
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.
Set it up
15 minutes- 1
Create the graph and its three hits
Content Browser▸ ContentRight-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 1AM_UPC_Sword_Combo0Light 2AM_UPC_Sword_Combo1Light 3AM_UPC_Sword_Combo2Tick 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 toUPC.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.ROOTUPC.Input.LightAttackLight 1AM_UPC_Sword_ComboUPC.Input.LightAttackLight 2AM_UPC_Sword_ComboUPC.Input.LightAttackZoom -1Light 3AM_UPC_Sword_ComboThree 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
Content Browser▸ ContentRight-click in the Content Browser, UPC, Items, Item Definition. OpenItem_MySwordand set Slot Tags toUPC.Slot.Weapon.Sword, so the demo belt's weapon slot takes it. Under Fragments, press +, pick Visuals and set Mesh toSM_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 rowUPC.Place.Main(the right hand) the demo sword's grip: Offset Location-9.86,2.70,-0.45, Rotation Y-90.Item_MySword▾FragmentsIndex [ 1 ]NoneDrawing 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 readTraceStartandTraceEnd, onSM_UPC_Sword's guard and tip.Item_MySword▾Trace SocketsIDNoneSource Component TagNoneShapeSphereA capsule from TraceStart to TraceEnd, swept while a trace window plays. The ID must readBlade, the name each trace window sweeps;UPC.ItemMeshtags the item's mesh in the hand. - 6
Put it in the hands and swing
AddItem_MySwordto Starting Items on the InventoryComponent ofBP_UPC_Character(Demo/Characters/Player), or of your copy once it is the game mode's Default Pawn Class (see Getting Started). PlayLVL_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.AM_UPC_Sword_Combo
0.0
0.25
0.5
0.75
1.0
1.25
1.5
1.75
2.0
Sections
0
1
2
Trace
Melee Trace: Blade
Melee Trace: Blade
Melee Trace: Blade
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).
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
- 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.
- Make a damage config: UPC, Damage and Defense, Damage Config. Its Damage starts at 10.
- Add a trace window to each swing: Add Notify State..., UPC Melee Trace Window, across the frames where the blade connects, with Socket IDs
Bladeand your Damage Config. - Point each node at its Montage and Section Name.
See Melee Trace and 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 shows how to find the grip Offset.The demo sword
| 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). |
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 walks through the parry, the guard and the demo's other moves. |
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
C++Grant a graph or an item from code
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.
AdvancedTroubleshooting
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 1shows ROOT. - The swing hits nothing: no volume named
Bladeregistered. The row's ID differs, its Source Component Tag names a component nothing carries, the mesh lacksTraceStartorTraceEnd, or the sword sits in a place other than the first of its Hold Places, which registersBlade_Off. The Output Log names a refused row.