Character Setup

Documentation Unreal Engine Player Combat Tutorial

Make a character of your own fight without changing its parent class: the components to add, the settings they need, the ready signal and the interface that answers hits.


The quick start uses the demo's fists, made for the demo mannequin's skeleton and its hand_r and hand_l bones. On another skeleton, make your own punch montages and give each hand a hit volume as Build Your First Combo does for the sword. For a right hand bone named RightHand, add a Trace Sockets row to the fists item's Equippable fragment, and put a UPC Melee Trace Window naming the same ID on the punch montage:
Item_MyFists
▾Trace Sockets
IDNone
Socket or Bone NameTraceStart
An empty Source Component Tag traces the body mesh. The punch's trace window lists FistR under Socket IDs.
Make the fists item by duplicating Item_UPC_Unarmed, point its Equippable Action Graph at a graph whose montages fit your skeleton, and set it as the Equipment Manager's Default Item. Set the Equipment Manager's Body Places to your hand bones too (defaults hand_r and hand_l; Equipment). A character free to change its parent can reparent to UPC Character Base instead.

Set it up

10 minutes
  1. 1

    Add ten components

    Press Add in your Character Blueprint's Components panel.
    Components
    + Add
    BP_MyCharacter (Self)
    Capsule Component
    Mesh
    Ability System
    Add
    UPC Action Graph
    Add
    UPC Input Mapping
    Add
    UPC Inventory
    Add
    UPC Equipment Manager
    Add
    UPC Melee Trace
    Add
    UPC Anim Manager
    Add
    UPC Vitals
    Add
    UPC Defense
    Add
    UPC Team
    Add
    Names as the Add list shows them.
  2. 2

    Fill in four settings

    • UPC Vitals: add a Vitals row with Vital Tag UPC.Vital.Health and Max Value 100. A Vitals component added by hand has none.
    • UPC Team: Team Id 0, the demo player's side. A new Team component starts on 1, the demo enemies' side.
    • UPC Equipment Manager: Default Item Item_UPC_Unarmed, the demo's fists, which give the moves when nothing else is in hand (on another skeleton, your fists item).
    • Mesh: the Component Tags UPC.Montage, where montages play, and UPC.Attachment.Body, where items hang. With no UPC.Attachment tag, items spawn unattached.
  3. 3

    Send the ready signal

    Call Notify Ability System Ready from Event BeginPlay and Event Receive Controller Changed. It grants the abilities that need no key: hit confirmation, draws and put-aways, the paired role and the interactor's payload ability. Abilities a key starts (lock-on, interact, sprint) come from an ability set (below). Begin Play covers the ability system; the controller call covers the Default Item, which adds its keys once a player controller holds the character.
    BP_MyCharacter · Event Graph
    Event BeginPlay
    Notify Ability System Ready
    Avatarself
    Ability System
    Event Receive Controller Changed
    Old Controller
    New Controller
    Notify Ability System Ready
    Avatarself
    Ability System
  4. 4

    Answer incoming hits

    In Class Settings, add the UPC Damageable interface. Its Handle Incoming Damage returns Resolve Defense and Apply Damage, with the UPC Defense component as Defense and Health Vital Tag UPC.Vital.Health.
    BP_MyCharacter · UPC Damageable interface
    Handle Incoming Damage
    Damage Info
    UPCDefense
    Resolve Defense and Apply Damage
    Target is UPC Defense Statics
    Defense
    Damage Info
    Health Vital TagUPC.Vital.Health
    Return Value
    Return Node
    Return Value
  5. 5

    Check the Animation Blueprint

    Your Animation Blueprint needs a Slot node for DefaultSlot, where the punches play, then UPC Hit Stop and Inertialization after it, or the log warns once (The Animation Blueprint lists the rest).
  6. 6

    Press Play and punch

    Make your character your game mode's Default Pawn Class, point a copy of LVL_UPC_Demo's GameMode Override at that game mode, and press Play. Punch a training dummy with the left mouse button.

What each component does

ComponentDoes
Ability SystemPlays each move as a gameplay ability.
UPC Action GraphPicks the next move: the current node, its action window, a press waiting to chain.
UPC Input MappingTurns keys into input tags for the graph. Drawn items add their keys here.
UPC InventoryWhat the character owns, starting with its Starting Items.
UPC Equipment ManagerDraws and puts away items, hands the character the drawn item's graph and keys, and falls back to the Default Item.
UPC Melee TraceSweeps drawn items' hit volumes during trace windows, passing over teammates.
UPC Anim ManagerNames the mesh items hang on, links item animation layers, mirrors montages to extra meshes, holds the pose on hits.
UPC VitalsHealth, and any pool you add, such as stamina.
UPC DefenseParries, blocks, invulnerability. Empty, it lets each hit land in full until a drawn item lends it rules.
UPC TeamThe character's side.

Add more for more features

FeatureAdd
Attacks that turn and close the gapUPC Targeting with a Targeting Config, UPC Attack Approach, Motion Warping
Lock onThose three, and a lock press (below)
Be locked ontoUPC Targetable
A combat style for rotation, targeting and cameraUPC Combat with a Combat Style
Doors, chests and pickupsUPC Interactor, and an interact press (below)
Sprint on a held buttonUPC Sprint, and its ability (below)
Put-away items shown on the bodyUPC Stow Visual
Flinching bones, a ragdoll on deathUPC Physical Reaction
Warnings over an enemy's swingUPC Telegraph Viewer
Footsteps and effects from animationUPC Anim Effects with an Anim Effect Bank
UPC Character Base creates every component on this page but Motion Warping, UPC Sprint, UPC Stow Visual, UPC Physical Reaction and UPC Telegraph Viewer.
Lock-on, interact and sprint are abilities on a key, separate from the ready signal's. UPC Character Base grants them from its Starting Ability Set; your Blueprint has no such slot, so an item grants them instead: on the Default Item they work bare-handed, on a sword only while it is drawn. For lock-on:
  1. Create a UPC Ability Set (right-click in the Content Browser, UPC, Actions, Ability Set). Add a Granted Gameplay Abilities row: Ability UPC Lock On Ability, Input Tag UPC.Input.LockOn, Input Action IA_UPC_LockOn.
  2. Add the set to Ability Sets to Grant on the Equippable fragment of each such item. For the demo fists, duplicate Item_UPC_Unarmed and make the copy the Default Item.
  3. Give IA_UPC_LockOn a key: IMC_UPC_Default, which BP_UPC_PlayerController adds, maps it to the middle mouse button. With a controller of your own, map it in a context that controller adds.
Interaction and sprint take a row each in the same set: UPC Interact Ability on UPC.Input.Interact and IA_UPC_Interact, UPC Sprint Ability on UPC.Input.Sprint and IA_UPC_Sprint.

Draw items from a belt

  1. Add UPC Quick Bar to your player controller, or use UPC Player Controller, which carries one.
  2. On your own controller, bind On Possessed Pawn Changed and call the Quick Bar's Initialize for Pawn with a valid New Pawn, on the server and the player's machine alike.
  3. Tick Auto Populate from Inventory and list items in the inventory's Starting Items: each takes the first free slot, and the first that fits comes to hand.
A character with no belt, such as an AI, draws on the server with Equip Item or Draw With Reach.

The Animation Blueprint

  • A Slot node for each slot the montages use: DefaultSlot unless you pick another. The demo's montages also use UpperBody for draws, parries and pickups.
  • UPC Hit Stop after the slot, then Inertialization: freezes the pose briefly on a hit.
  • Optional Linked Anim Layer nodes take a drawn item's animation layer (its own walk, say); without them the layer is ignored. The demo's layers fit ABP_UPC_MannequinBase or a child.
AdvancedWhat only the character base does
The baseOn your character
Moves with UPC Character Movement: smoother corrections under lag, and a Grace Tag that keeps the server from pulling a dashing player backC++, since a Blueprint cannot change the movement component's class; every feature works on the engine's Character Movement
A Health row on its VitalsStep 2
Draws its starting items, unless a belt that takes new items doesEquip Item for each, on the server, from Begin Play
Ignore Camera Collision: the camera's spring arm passes through charactersThe Camera channel on Ignore on the capsule and mesh
No character can stand on its headThe capsule's Walkable Slope Override, Walkable Slope Behavior Unwalkable

Debug it

UPC.Debug.Actions 1      // Each character's node, window and waiting press
UPC.Debug.Anim 1         // The meshes found, and which plays montages
AdvancedLeaving a component out
  • Ability System: no move runs, and setting a graph warns.
  • UPC Input Mapping: no key reaches a move unless your input calls the graph's Process Action Input.
  • UPC Melee Trace: no hits; an item with hit volumes warns as it is drawn.
  • UPC Anim Manager: montages play, but items do not attach, and item layers and hit stop do not run.
  • UPC Team: teamless; enemies still target it, and teammates' swings still hit it.
  • Motion Warping: an attack with a warp window plays its own motion and steers nothing; the log warns once per class.
AlternativeUse the character base instead
File, Reparent Blueprint, UPC Character Base, then delete the components your Blueprint added that the base creates, a UPC Team among them. Set Team Id on the base's Team Component, which starts on no team (255), tag the mesh and set the Default Item. The demo player, BP_UPC_Character, is built this way.
MultiplayerMultiplayer
  • The ability system stays on the character; a Blueprint cannot put it on the PlayerState. Added in Blueprint, it replicates in Full mode, which suits players and AI.
  • The ready signal is safe on every machine: only the server grants abilities.
  • Without the ready signal, a client player's hits do not reach the server, and that client logs it.
  • A graph set with Set Action Graph goes on every machine: it does not replicate, and the owning player predicts with it.
C++C++
  • A C++ pawn may host its ability system on the PlayerState, as AUPCCharacterBase does. It calls InitAbilityActorInfo(Owner, this) on possession and when the PlayerState arrives, RefreshAbilityActorInfo() from NotifyControllerChanged (a client can receive the PlayerState first), and UUPCAbilitySystemReady::NotifyAbilitySystemReady(this, AbilitySystem) after each.
  • IUPCDamageable::HandleIncomingDamage_Implementation makes one call, UUPCDefenseStatics::ResolveAndApplyIncomingDamage(Defense, DamageInfo, HealthVitalTag).
  • UUPCAbilitySet::GiveToAbilitySystem and RegisterInputMappings grant an ability set and its keys. UUPCInputMappingComponent::BindInputs, from SetupPlayerInputComponent, binds the component's own Input Mappings.
  • SetDefaultSubobjectClass<UUPCCharacterMovementComponent>(ACharacter::CharacterMovementComponentName) gives a character UPC Character Movement. A C++ child of the base passes its own movement class to the protected constructor AUPCCharacterBase(const FObjectInitializer&, TSubclassOf<UCharacterMovementComponent>).
  • A movement component of your own takes UPC Character Movement's fixes by copying from UUPCCharacterMovementComponent:
    • FUPCSavedMove (Clear, SetMoveFor, CanCombineWith, PrepMoveFor, PostUpdate, GetCompressedFlags), its casts pointed at your component; unchanged, it treats every run as predicted. The prediction data's AllocateNewMove.
    • AddReferencedObjects, GetPredictionData_Client, ClientUpdatePositionAfterServerUpdate, ClientHandleMoveResponse, UpdateFromCompressedFlags, MoveAutonomous, SimulatedTick, TickCharacterPose, and ServerCheckClientError, ServerShouldUseAuthoritativePosition and ServerMoveHandleClientError as the overloads taking FMovementBaseInterfaceData* from UE 5.8, UPrimitiveComponent* before.
    • FUPCMoveResponseData with its CorrectedMove fields and two overrides, set in the constructor with SetMoveResponseDataContainer and returned by GetUPCMoveResponseData.
    • Every member those bodies use, among them FUPCMovementSettings with its static_assert, and the file-local FindStraightGlideTarget and HoldToLine.
AdvancedTroubleshooting
The character does nothing when the key is pressed
  • No Default Item, or one with no Action Graph: UPC.Debug.Actions 1 shows no graph.
  • No key reached it: the Default Item adds its keys once a player controller holds the character, so check the controller-changed call.
  • No montage plays: the Animation Blueprint lacks the montage's Slot, or the montage is for another skeleton.
  • The press is refused: the character carries a Global Block Tags tag of the UPC Action Graph, UPC.State.ActionsBlocked by default.