Hello everyone,
I’m developing a co-op survival game and I’ve run into a multiplayer UI issue that I can’t seem to solve.
The Problem: When a client uses a consumable item from their inventory, the item is correctly used and removed from the inventory data. However, the UI does not update in real-time. The used item slot only disappears after I close and reopen the inventory widget.
My System Setup:
-
BP_InventoryComponent
: An actor component on my player character. It holds the inventory data.-
It uses a non-replicated
TMap
for the server’s master list. -
It has a
RepNotify
TArray
of a struct, which acts as a replicated “mirror” of the inventory for clients.
-
-
WBP_InventoryScreen
: The main inventory widget. -
WBP_InventorySlot
: The widget for each individual item.
The Logic Flow: My update logic is designed to work like this:
-
The client clicks on a
WBP_InventorySlot
, which calls aServer_UseItem
event on thePlayerCharacter
. -
Server_UseItem
callsServer_RemoveItem
on theBP_InventoryComponent
. -
Server_RemoveItem
correctly updates the server’s masterTMap
and then calls a function (UpdateReplicatedItems
) to sync theTMap
to theRepNotify
TArray
. -
This change in the
RepNotify
TArray
correctly triggers theOnRep_ReplicatedInventoryItems
function on the client. -
Inside the
OnRep_
function, I call an Event Dispatcher namedOnInventoryUpdated
. -
In my
WBP_InventoryScreen
’sEvent Construct
, I get a reference to the inventory component and use aBind Event to OnInventoryUpdated
node. This node is connected to myPopulateSlots
function, which clears and redraws all the item slots.
What I’ve Debugged: I have used Print Strings and confirmed the following:
-
The
OnRep_ReplicatedInventoryItems
function IS firing correctly on the client after an item is used. -
The
OnInventoryUpdated
Event Dispatcher IS being called correctly from within theOnRep_
function.
It seems the signal is being sent, but the UI widget isn’t “hearing” it or reacting to it, even though the Bind Event
node is set up.
I’m hoping someone can spot what I’m missing. Why isn’t my UI refreshing in real-time?
Thank you for your time!