Quick Bar

Documentation Unreal Engine Player Combat Quick Bar Equipment

The quick bar is a belt of slots on the player controller, each holding one owned item. A key per slot draws its item or puts it away; an item that cannot be held, such as a potion, is used instead.


Set it up

5 minutes
  1. 1

    Make a player controller with a belt

    Create BP_MyPlayerController, a Blueprint child of UPCPlayerController, and set it as Player Controller Class on the demo level's BP_UPC_GameMode. On its Quick Bar Component (three empty slots) tick Auto Populate from Inventory so new items take free slots. It replaces BP_UPC_PlayerController, so the demo's keys, HUD and inventory screen are gone while it is set.
  2. 2

    Give each slot a key

    Make three Input Actions with a Pressed trigger, mapped to 1, 2 and 3 in an Input Mapping Context of your own. In the controller's Begin Play, call Add Mapping Context on the Enhanced Input Local Player Subsystem. From each action's Triggered pin call Press Slot with Slot Index 0, 1 and 2.
    BP_MyPlayerController · one belt key per slot
    EnhancedInputAction IA_SelectSlot1
    Triggered
    Action Value
    Quick Bar Component
    Press Slot
    Target is UPC Quick Bar
    Target
    Slot Index0
  3. 3

    Give the character items

    On BP_UPC_Character's InventoryComponent, keep Item_MySword (from Items) in Starting Items and add Item_UPC_Potion after it. Each takes the first free slot that admits it, and the sword comes to hand.
  4. 4

    Press Play, then 1 and 2

    Press 1 to put the sword away, 1 again to draw it. Press 2 to drink the potion through the use ability BP_UPC_Character's ability set grants (Inventory).
    Then set BP_UPC_GameMode back to BP_UPC_PlayerController; later pages use the demo's keys and screens.

Lay out the slots

Each slot's Filter decides what it takes. None takes any item, worn gear included, as in a survival hotbar: a ring goes on at its key and comes off at the next press, its slot never lights, and the drop key never drops it (a ring is not held in a hand). A tag takes items whose Slot Tags match it, children included; an item with no Slot Tags fits unfiltered slots only.
The demo's item kinds live under UPC.Slot (.Weapon, .OffHand, .Consumable, others), which inventory rules and sorting read too. Add yours under them (UPC.Slot.Weapon.Spear).
A copy limit caps how many slots hold one item: the item's Belt Limit fragment, else the belt's Default Max Copies Per Definition (0 for no limit). It limits the belt only.

A belt an inventory config names

The inventory config can name its own belt. Its Belt Slots (a Slot Tag per slot, an empty entry for any item) replace the belt's own Slots while the inventory uses that config; with no entries the belt's own slots return. On a switch, an item its slot still accepts stays; one it refuses leaves the belt for the inventory (or stays in hand if drawn).
Untick Has Belt on the config for no belt: its keys do nothing and nothing goes on it, items on it stay in the inventory and an item in hand stays in hand. A config with a belt returns the slots empty. UPC.State.BeltBlocked below instead keeps every assignment and only switches the belt off. The demo's open world list has no belt; its HUD and screen show none.

A combat style without a belt

Put UPC.State.BeltBlocked in a combat style's Gameplay Tags fragment (Combat Styles); the belt's Blocked Tags list it by default. Under that style key presses do nothing, pickups stay off the belt and the belt draws nothing on its own; slots keep their items and Request Assign Slot still works.

Fill the belt

The UPC Quick Bar sits on the player controller, so it outlives the character, and needs a UPC Inventory and UPC Equipment Manager on the pawn (the character base has both). A slot holds one whole stack and keeps its index. Only carried items in reach (Containers and Rules) go on the belt or get drawn or used from it.
Details
QuickBarComponent
UPC
Quick Bar
Slots
3 Array elements
Index [ 0 ]
Filter
None
Index [ 1 ]
Filter
None
Index [ 2 ]
Filter
UPC.Slot.Consumable
Blocked Tags
1 Gameplay Tag
UPC.State.BeltBlocked
Default Max Copies Per Definition
0
Auto Populate from Inventory
Auto Draw on Init
Restore when Place Frees
Weapon Keeps Its Place
Refill Item Kinds
1 Gameplay Tag
UPC.Slot.Consumable
Driver Replacement on Drop
None
Three slots by default. Leave a Filter at None for a slot that takes anything; the third slot here takes consumables only. Auto Populate from Inventory is ticked here, as the quick start does; it is off by default.
With Auto Populate from Inventory on, each new stack the character carries takes the first free slot its Filter and copy limit allow, or stays in the inventory only. With none free, a slot whose item another free slot takes makes room: a sword on the off-hand slot moves up to a free weapon slot so a shield takes the off-hand slot. An item a combine makes takes only a slot its ingredient emptied. Auto Draw on Init, on by default, brings a new item to hand with no reach when that puts nothing away (a starting item or a pickup); otherwise it waits for its key. A new pawn with another inventory empties the slots and refills them, keeping the Filters.
With Auto Populate off, the default, a screen asks for a slot with Request Assign Slot from the player's machine, checked first with Can Assign Slot (Inventory Screens). Server code uses Add Item to Slot, which respects the Filter and draws nothing, and Remove Item from Slot, which puts the item away first.
Refill Item Kinds says which items refill their slot when the stack there runs out or leaves: the slot takes another carried stack of the same item in reach, so twelve potions stay on the belt as each stack of five is drunk. It matches the item's Slot Tags, children included. The default, UPC.Slot.Consumable, refills potions and leaves a dropped sword's slot empty; UPC.Slot refills every item, and an empty list refills nothing.
On a controller not built on UPCPlayerController, add UPC Quick Bar and call Initialize for Pawn from On Possessed Pawn Changed, skipping an empty New Pawn.

Pressing a slot

Press Slot starts the reach on the player's machine at once, then asks the server for the change. Toggle Slot skips the early reach; Draw Slot and Stow Slot go one way. An item with no Equippable is used: the belt fires On Slot Used on the server and sends UPC.Event.UseItem, as a screen's Use does.
While the character may not change what it holds (by default mid-move, or with UPC.State.EquipmentBlocked or a Blocked Tag), a press does nothing and is forgotten (Equipment).

When places are taken

A draw puts away whatever holds the places it needs (Equipment). Two belt settings, both on by default, add to that:
  • Weapon Keeps Its Place: a non-main-weapon never puts a drawn main weapon away, so a torch pressed while the sword holds its hand is turned down. Turn it off to let the torch take the hand.
  • Restore when Place Frees: a non-main-weapon put away or turned down by a main weapon returns once its places free (a shield put away by a two-hander returns when the two-hander goes; the torch above comes out). Pressing the waiting item's own key cancels its return.
Returning items draw in slot order, only when they put nothing away, once a running move ends.

Cycling and replacing the weapon

Cycle Driver Forward and Cycle Driver Backward hand combat to the nearest main weapon after or before the driving slot, wrapping around the belt: a weapon in hand takes over the moves, one put away is drawn.
When the weapon in hand leaves the belt (dropped, used up, removed), a replacement comes to hand. If Refill Item Kinds lists weapons, a spare refilled into the emptied slot is drawn. Otherwise Driver Replacement on Drop decides: None leaves it to another drawn item that can drive, else the Default Item; Nearest Forward, Nearest Backward and Nearest Bidirectional draw the nearest main weapon in a later slot, an earlier one, or either (earlier wins a tie), without wrapping. Driver Replacement Search Limit caps the slots searched. The replacement plays its reach (putting away an off-hand item in its way) once any running reach or move ends.
With the sword in hand on slot 1, a potion on slot 2, slot 3 empty and an axe on slot 4, dropping the sword gives:
  • Nearest Forward and Nearest Bidirectional: the axe.
  • Nearest Backward: nothing, since no slot comes before slot 1 and the search does not wrap.
  • Nearest Forward with a Search Limit of 2: nothing, since it looks at slots 2 and 3 only.
  • Any of them, with Refill Item Kinds set to UPC.Slot and a second sword carried: that sword, refilled into slot 1.

A belt on screen

On the server and the owning player's machine:
NodeAnswers
Get Slots, Get Item in Slot, Get Num SlotsThe items in slot order, one slot's item, the belt's size.
Is Slot DrawnWhether a slot's item is in hand (from the frame it arrives), for highlighting; hands are the Equipment Manager's Hand Places.
Get Driver Slot Index, Get Driver ItemSlot and item driving combat; -1 and nothing while none is drawn.
Get Slot FilterA slot's Filter.
Count Item Copies, Resolve Max Belt CountSlots holding an item; its copy limit.
Can Assign SlotWhether Request Assign Slot would land (Filter, copy limit, reach, room).
Bind On Slots Changed (contents), On Driver Slot Changed and On Slot Draw State Changed (highlights), On Item Removed (an item leaving a slot) and the inventory's On Item Count Changed (stack counts).

A belt on an AI

Add UPC Quick Bar to an AI controller, call Initialize for Pawn as it possesses, and press slots with Toggle Slot. An AI without a belt draws its starting items via Draw Starting Items.

Debug it

Log LogUPCEquipment Verbose logs why an item stayed off the belt (full belt, Filter, copy limit), a press turned down for a playing reach or a weapon in the place, and each reach step; a Can Change Equipment refusal logs nothing. The Output Log warns once when the pawn lacks a UPC Inventory or UPC Equipment Manager.
AdvancedThe belt in detail
  • Auto Populate leaves a split-off stack where it was dropped; an item a save restores takes its saved slot.
  • A returning item or replacement weapon waits while a reach plays or a move runs, then draws on the Equipment Manager's On Equipment Change Resumable. The restore sweeps the belt once; a reach it starts ends the sweep and the rest follow when it ends.
  • A pickup or forced draw putting a weapon in hand cancels a waiting replacement. A draw your Can Run Equipment Action refused waits for the next move end or belt change.
The demo
BP_UPC_PlayerController's belt is a diamond, in the order its input binds 1 to 4 and the D-pad:
SlotKeyD-padFilter
11UpUPC.Slot.Weapon
22RightUPC.Slot.Consumable.Potion
33DownUPC.Slot.OffHand
44LeftUPC.Slot.Consumable
Details
QuickBarComponent
UPC
Quick Bar
Slots
4 Array elements
Index [ 0 ]
Filter
UPC.Slot.Weapon
Index [ 1 ]
Filter
UPC.Slot.Consumable.Potion
Index [ 2 ]
Filter
UPC.Slot.OffHand
Index [ 3 ]
Filter
UPC.Slot.Consumable
Blocked Tags
1 Gameplay Tag
UPC.State.BeltBlocked
Default Max Copies Per Definition
1
Auto Populate from Inventory
Auto Draw on Init
Restore when Place Frees
Weapon Keeps Its Place
Refill Item Kinds
1 Gameplay Tag
UPC.Slot.Consumable
Driver Replacement on Drop
None
Driver Replacement Search Limit
0
The demo's diamond, slot by slot as the table above lists it. Clear every Filter for a belt that takes any item; its Default Max Copies Per Definition of 1 then keeps one of each item on it.
  • The potion's Belt Limit of 1 keeps it to the right slot, refilled from carried stacks by the default Refill Item Kinds. The one-handed sword is an off-hand kind too, with a Belt Limit of 2, so a second sword takes the off-hand slot; worn gear lands in no slot.
  • The party RPG's config names four Belt Slots taking any item, and the controller's Default Max Copies Per Definition of 1 keeps one of each item on that row, the sword excepted, whose Belt Limit is 2.
  • The Freeflow style holds UPC.State.BeltBlocked; the HUD shows the belt only under UPC.UI.Show.Belt, from the other two styles.
  • WBP_UPC_Belt and the screens' WBP_UPC_BeltPanel build their slots from the events above; the panel takes an item dropped on a slot. BP_UPC_EquipmentShowcaseController gives an AI a belt and presses a random slot every few seconds.
MultiplayerWhat runs where
The server owns the slots, draws and waits. The belt exists on the server and the owning player's machine, where slots replicate and slot events fire on arrival; On Slot Used and the use event happen on the server, as do Toggle Slot, Draw Slot, Stow Slot and cycling.
  • Press Slot plays the reach at once and the item arrives about a round trip later; a refused press blends the reach out.
  • Nothing is predicted: a slot's drawn state follows the character's replicated equipment. Other players see what a character holds through its equipment, never its belt.
C++C++
  • AUPCPlayerController calls InitializeForPawn from OnPossess and OnRep_Pawn. ToggleSlot, DrawSlot and StowSlot are reliable server RPCs; PressSlot plans via the equipment action's PlanDraw / PlanStow and plays the steps locally first.
  • The belt reports its items to the Equipment Manager, which preloads them, and on the server to the inventory, for Belt Space.