Client RPCs in PlayerCharacter in BeginPlay execute only on server

Hello everyone,
I have a problem calling a “Run on owning Client” RPC in my Player Character BP in the BeginPlay event. Below is the code I am trying to execute, nothing fancy.


When testing it in multiplayer with 2 players (one as listen server), the CL_Print event gets called twice on the server.
Output of the print string is this:
image
I can fix this easily by adding a delay node (~ 1-2s) right before calling the CL_Print event in BeginPlay. The print string then shows me this:
image
However I know that this is just a workaround and not ideal as you shouldn’t use delay nodes, it would take some time for the connected clients to do the stuff in the CL_Print event and with high latencies a fixed delay time maybe wouldn’t always fit.

So what would be a solution for this?

Thanks!

Can you use the Event Possessed to call Cl_Print? It happens only on the server after the client is connected

BeginPlay runs for both client and server so just use IsLocalPlayer Branch to run client logic

the reason your RPC fails is because the Server BeginPlay fires before the Client exists (due to lag) so the RPC is missed

2 Likes

Dirty hack (used to debug only) is to add a delay on begin play. Do 0.5s if playing from editor.

The reason this is a dirty hack is you cannot predict the delay for every possible connection, nor processing speeds of every pc configuration.

Proper fix is to have the client RPC the server when it’s ready. Then Server can RPC back whatever it wants. You need to dig into conditional flow logic pertaining to Proxies.

Get Local Role
is locally Controlled
Is Server, Is Dedicated Server


Here’s a couple common Function/Macro I use.

What each proxy does and can do is defined in a BeginPlay Init function.


For Listen Server setups I find using a custom macro (LS Switch has Authority) helps with flow logic.