Adding the Hotbar Component
Blueprint Setup
Open your Character Blueprint
Add Component → Hotbar Component
Configure properties, for example:
Max Slots:9Auto Refill Enabled:true
Optionally link to the main inventory in BeginPlay:
Event BeginPlay
↓
Get HotbarComponent
↓
Set Player Inventory
Inventory: [Main InventoryComponent]
C++ Setup
// In Character.h
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
UHotbarComponent* HotbarComponent;
// In Character.cpp constructor
HotbarComponent = CreateDefaultSubobject<UHotbarComponent>(TEXT("HotbarComponent"));
HotbarComponent->MaxSlots = 9;
HotbarComponent->bAutoRefillEnabled = true;
// In BeginPlay
void AMyCharacter::BeginPlay()
{
Super::BeginPlay();
HotbarComponent->SetPlayerInventory(InventoryComponent);
}