UE5 Inventory and Item System
This page is part of the documentaiton for my UE5 Inventory and Item System

Hotbar System

UE5 Inventory and Item System Version: 3.0

    The hotbar is where the player can place important items they want to easily access. It is primarily used for weapons and consumables, but you can put any kind of item on it.

    Change Hotbar Slot Count

    The player hotbar slot count is changed the same way as the player inventory. Select the AC_InventoryItemSystem component attached to your player controller then navigate the details panel to the Player Settings section and expand it to expose the HotbarSlots variable. Set this variable value to the number of slots you want available on the hotbar. You will have to manually add additional input actions to support your new slots (see the slot key bindings section of this chapter below for instructions).

    Change Hotbar Columns (multiple rows)

    By default the hotbar column size is set to the same number of slots used by the hotbar AC_Inventory component. If you wanted to have two rows of 5 slots you will want to edit the BuildHotbar function inside of the UI_Hotbar, the getRowColumn calls is what you will want to change the Column value for (there are 2 in this function, one for the actual slot, the other is for the key binding text that appears above the slot) .

    When using multiple rows keep in mind that the gamepad is only set up to cycle left to right with it, which means using the left-right navigation at the end of the first row will move the focus to the next row on the next right nav press.

    At the same time there are no key bindings to support navigating up and down in a multiple row hotbar. You will have to add this functionality yourself by adapting the logic I am using to navigate the grid for things like the inventory, storage container and banker.

    Slot Key Bindings

    By default the hotbar includes 10 keybindings for the first 10 hotbar slots. The keybinding set with enhanced input action using the IMC_InventoryItemSystem collection. If you add more slots to your hotbar and need to add key bindings for new slots, or if you want to change the current keybindings for an existing slot you will do this inside the IMC_InventoryItemSystem.

    To change a current key binding …

    Open the IMC_InventoryItemSystem located in the Blueprints/Input/ folder and expand the item for the hotbar slot you wish to change. Click the keyboard icon next to the current key binding and press the key you wish to use on your keyboard, mouse or gamepad.

    To add a new hotbar slot key binding …

    First duplicate one of the IA_Hotbar actions found in the Blueprints/Input/Hotbar folder.

    Then open the IMC_InventoryItemSystem and add your new action to the list. Expand the newly added action and add an element to it, then set your key binding using the keyboard icon.

    Next is integrating your new IA_Hotbar action in the UI_Hotbar. Open the event graph of the UI_Hotbar and navigate to the input handlers section. This is where you will want to place your new IA_Hotbar action, and then have it call the HotbarButton with the appropriate hotbar slot index like all the other input actions are doing.

    The last part involves helping the system identify the hotkey to show, and we do this with the HotbarInputActions array inside the UI_Hotbar Each index in this array is the slot, starting at 0. The input action for that slot should be the value. Without doing this last part your key binding will never appear on the hotbar slot, even though it will still work just fine.

    The text on the hotbar slot will update automatically based on the data it is able to pull from the enhanced input system. It will only try to show the text for the first key binding inside the IMC_InventoryItemSystem for the particular binding, and only if it is not already being consumed elsewhere in your project. Take a look at the GetKeybinding function inside of the AC_InventoryItemSystem to see how it works.

    Equipping Weapons

    One of the primary uses of the hotbar in this system is for equipping and swapping equipment used by the Main Hand (a default equipment slot). If you do not want to use the hotbar for weapons you will need to do a few things:

    • First set the EquipWeaponsOnHotbar? boolean on the AC_InventoryItemSystem attached to your player controller to false.
    • Next you will need to add your main hand slot to the UI_Equipment_Tab in the UIs/Equipment/ folder. Make sure you read the chapter for instructions on how to do this.
    • If you like the functionality of weapons on the hotbar but just want to change the slot that is used you will have to open the AC_InventoryItemSystem component and set the value of HotbarEquipToSlot to the slot you want to use.
    • You will also want to make sure that the slot does not exist in your UI_Equipment_Tab as you could run into some unexpected behavior with the slot being used at the same time in both the equipment window and through the hotbar.

    Using Usable Items

    The other primary purpose of the hotbar is to quickly use usable items. Keep in mind when using usable items that produce items you will most likely want to make sure the items it produced are added to the inventory and not the hotbar. In our demo world the loot box has this functionality. You can equip the loot box to the hot bar, then if you press the hotkey for it the loot box will be used, however the loot from it is moved to the inventory. This functionality is happening inside the ItemOnUse handler.

    To make usable items take a look at the section titled Usable Items in the Item System chapter.

    Show / Hide the Hotbar

    You can easily show and hide the hotbar at any time by calling the showHotbar and hideHotbar global functions. Since these functions are in the BP_SharedFunctions blueprint function library in the Blueprint/Variables/ folder you will be able to access them from anywhere in your project. For multiplayer you need to keep in mind though that the server has no control over the client’s UI. So don’t try to show or hide the hotbar when doing something that only occurs on the server, you have to run on client from the server. Keep in mind even with the hotbar hidden it can still be used. To disable functionality of it you will want to disable the hotbar instead.

    Enable / Disable the Hotbar

    You can also enable and disable the hotbar to prevent the user from using it at specific times in your game. Like the Show & Hide hotbar functions you will also find enableHotbar and disableHotbar inside the BP_SharedFunctions blueprint library located in the Blueprints/Variables/ folder.

    This documentation and asset version are new. If you encounter any bugs or if anything doesn't make sense, please let me know.