Actor Clicked > Cast to Player State Custom event > Custom Event Execute on Server > Custom Event Execute Multicast >
When I test the game some times the client can properly trigger a series of custom events that replicates to all clients. But other times the client gets stuck and does not make it past the execute on server custom event. No changes. Just totally random with each time I press play to test.
Gotcha. I set the RPC’s to reliable, but the issue remains. I uploaded a video of the issue to dropbox if you want to take a look.
It will work consistently, but then suddenly the client’s Player_State will fail to execute the ‘On Server’ RPC. It either works perfectly, or not at all. Very weird.
Did you try to also do a print directly before the RunOnServer rpc to see whether it executes the call to the server (between toggle set player state and server)?
Are you creating and hosting a session ? because I see you’re doing it as already being a client. I suggest playing with 2 standalones and not in dedicated/listen server.
Can you add a print to the cast failed because the player state is also something that gets replicated to the client, It’s worth checking if it’s valid, maybe this fails sometimes.
I am! I was actually about to post about it. Here’s the current set up… Level “Main Menu” loads a host/join widget, “host” creates a session and loads the “Main Level” as seen below.
I changed it, still no dice. I also added a failed cast print, and a print before the server RPC.
2 Stand Alone Clients
“Host” Player
“Join” Player
edit: Forgot to say, those two screen shots are separate tests. The “Host” player will execute and the widget will replicate the green appearance on the “Join” player.
Right now I suspect the GetPlayerState node, I think it might not be returning the locally controlled player state, replace it with this
Actually just read the description, it’s probably it.
In multiplayer you have access to all players player state, the get player state node will return one based on index and not necessary your own player state.
Try adding this check, it should print true if that player state is yours, if it does and you still can’t send the server event then something is weird going on. Also delete those new param just in case.
Interesting, that’s weird, it could be a glitch that happens in editor only.
You can try doing the server event in the player controller and only the multicast in player state.
Execute server on player controller
Player controller access the player state and calls the muticast
Don’t use get player state though, remove that node anywhere you have it. In player controller you can access it directly