Hi all,
I’m having trouble with my inventory system in a multiplayer project in Unreal Engine. The server is accurately tracking the inventory, but the client HUD is not reflecting the changes correctly. Here’s a summary of my setup and what I’ve already tried:
Setup:
- Inventory Component: Attached to the player’s pawn (BP_Player_Character). It tracks an
Items
array that is set toRepNotify
. - HUD: Displays the player’s inventory, which references the pawn to access it’s Inventory Component to update the UI.
- Replication:
Items
array is marked asRepNotify
.- Inventory Component is set to replicate (both in class defaults and on the component itself).
- The pawn is correctly replicated and controlled on the client.
What’s Working:
- Inventory system and HUD is working as intended for the Server pawn.
- The
OnRep_Items
function fires on the client when the server modifies the inventory. I confirmed this with print statements. - PlayerController references a pawn on the client (BP_Player_Character_C_2), this pawn is valid and all other functionality is working as expected (movement, interactions, attacks).
- The server correctly tracks the inventory for the client’s pawn. It is able to add new items and detect when the inventory is full.
The Problem:
- Despite
OnRep_Items
firing and replication seemingly working, the inventory HUD does not update on the client side. - Changes to the
Items
array on the Inventory Component aren’t being reflected in the HUD.
What I’ve Tried:
- Double-checked replication settings: Both the Inventory Component and
Items
array are set to replicate. - Reassigning the array after modification to ensure
OnRep_Items
triggers. - Fetching the Inventory Component from the client’s pawn in
OnRep_Items
to update the HUD. - **Creating a custom event that runs on owning client to force update of HUD.
What could be causing the inventory changes to replicate but not properly reflect on the client HUD? Based on my testing it seems like the issue is either the replication of the inventory component on the remote pawn, OR the Pawn reference is somehow invalid on the HUD.
Any help would be appreciated!