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.
Hi, did you try to make the RPCs reliable?
Checking this checkbox:
Because otherwise they may get dropped.
I did not, what exactly does Reliable mean? And should I set the Execute on Server AND Multicast both reliable?
RPCs may get dropped due to bandwidth issues. If the RPC is reliable, then if it gets dropped it will send it again and again until it gets through.
And should I set the Execute on Server AND Multicast both reliable?
I would set any RPC that must get through to reliable.
For cosmetic one shot things like spawning a particle system when a weapon fires, those RPCs should not be reliable.
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)?
I did. Here’s the result.
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.
Did you change it or you’re still running the same setup as your video, here it says client before joining/hosting.
I changed it, still no dice. I also added a failed cast print, and a print before the server RPC.
2 Stand Alone Clients
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.
Can you show where the “player state executed” print is called ?
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.
You can also do this
Let me know.
Both iterations return true for Client_0 and Server. Removed the new parameters also.
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
So far so good! Not sure what the take away is here, but it seems to be working now. Thank you so much Kaidoom15!
That’s good to hear, hopefully it keeps going well.