Zum Hauptinhalt springen

Inventory Component

Add UInventoryComponent or a Blueprint child to a Pawn/Character or PlayerState. The constructor enables component replication by default and disables ticking. A networked owner must also replicate and be relevant to the clients that should receive its inventory.

Configuration​

FieldDefaultMeaning
InventoryIdentityTagunsetExact tag used to find this component
CapacityTypeNoneCapacity policy; configure explicitly
MaxInventoryCarryWeight25.0Used by WeightBased and Hybrid checks
MaxInventorySlots10Used by SlotBased and Hybrid checks

Inventory component configuration

PolicyChecks
SlotBasedExisting free stack space and available entry slots
WeightBasedCurrent carry weight plus requested item weight
HybridBoth slot and weight limits
NoneFull-add check returns false; partial-add helper applies neither constraint

Configure SlotBased, WeightBased or Hybrid for predictable behavior. None is not a consistently implemented disabled/unlimited policy. Keep MaxStackSize > 0, limits nonnegative and item weights positive for weight-limited operations; the partial-weight calculation divides by Weight.


Identity Tags​

Use a distinct tag for each inventory in one Pawn/PlayerState lookup context. Examples include Cube_Inventory.Target.Character.Inventory, Cube_Inventory.Target.Character.Safelock, Cube_Inventory.Target.PlayerState.Currencies and Cube_Inventory.Target.PlayerState.Permanent. Another player's corresponding component can use the same tag because lookup also receives the Pawn.

Component added to a Character Blueprint


State and Events​

GetInventory() returns the current entries. ActualInventoryCarryWeight is replicated separately. Subscribe to OnSlotAdded, OnSlotRemoved, OnSlotUpdated and OnInventoryWeightUpdated for presentation. Read a snapshot when opening a widget so it also includes entries received before binding.

Fast Array receive callbacks drive slot events; the reviewed native mutation helpers do not broadcast equivalent slot events locally on the server. Verify listen-server UI separately. AddItemToSlot also omits a carry-weight refresh, documented under Implementation Limits.