I’m using Blueprints and need to get EventDispatcher events replicated from a server to clients.
I know that it’s suggested to use NetMulticast RPC for this, but I’m just wondering whether it’s possible to just replicate the EventDispatcher so that when it’s called on the server, the clients’ bound events are executed.
I have set up an MVP that is showing that setting Replication property of the EventDispatcher to Replicated does nothing:
Here, please note that GameState has EventOccured event dispatcher with Replication set to Replicated, also OnEventOccured event bound to the event dispatcher that updates the variable of the object and prints a message.
In practice, firing EventOccured event on the server calls OnEventOccured custom event only on the server. I can see this because Print String prepends "Server: " to the output message. The Client’s version of the event and “Number Of Events” variable stay intact.
So, is there a way to replicate event dispatcher from the server to clients, or NetMulticast RPC is the only way to go?
Got it: My problem was I have tested GM and GS in the same BP and on GM it failed on “cast to” on clients so the Dispatcher binding on clients was never made.
After fixing that, it worked fine. The way to go is:
On GameState on Server make a Multicast and on the Multicast call the Dispatcher on which you want all Clients know about
Of course all clients have to bind the dispatcher from the game state before an the actor where it is needed
Of course, when you are not already on the server when you start the mutlicast on gamestate, do a “on server” RPC on any actor it fits good, then inform Gamestate on server-side, then make the Mutlicast on Server-side. Multicast only works on server side.
I tested a bit more with the “replication” settings in the dispatcher settings. They have no influence I guess.
I guess Dispatcher can not be replicated on another way. Dispacther have to be called after replication.
Did you fine any solution? I also saw the “Replication” settings in the properties of the dispatcher. Really wired to have properties showing “replication” options but do nothing when used.
But I have another problem. As you write, you can do RPC Multicast and then the Dispatcher call works for all clients. I have also issues here. I bound a gamestate Dispatcher to all (local played) PlayerController and when I call the dispatcher in gamestate (after Multicast) its still not calling the bound dispatcher on all clients. Any ideas thy?
On game mode I tried the same. Here I think the “problem is”, because game mode is not replicated to clients at all. But I am really wondering why gamestate dispatcher call are not shown on my clients who have this dispatcher bound.
Any help on this?
Thanks a lot