Call a method on server spawned actor on all clients

TheKing530
Tue, 19 Oct 2021 09:00:49 +0000
Blueprint

Hello all!

Bit of an interesting question. I’ve got the following setup for an item use system (think Skyrim/Fallout style):

1. Client controlling a Pawn opens their inventory (UI) and presses a button for an item.

2. UI calls a method on the Pawn which is marked as “Server” in the UFUNCTION() which takes the item data as a parameter.

3. Server receives the RPC call and uses the item data to spawn the item, and all clients have the item appear in their worlds.

So far, this works fine. The issue is that step 4 of this process requires the server to call a multicast method on the player entity which takes the spawned item as a parameter. However, if I do that, the newly spawned item will be null on all connected clients (likely because the replicated actor has yet to arrive at the client). Do you guys have a best practice/better approach for something like this? How can I execute a method from the server on all connected clients which takes a newly spawned actor as a parameter?

3 posts - 1 participant