Multiplayer Event Dispatcher

Hi,

I am having some trouble with finding a solution to use Event Dispatchers as a Client.

My code works well as a Server but it does not work for any of the clients…

What I do is call from a Character Blueprint, the Event Dispatcher which is placed in the Level BP.

First image and Second image are from the Character BP.

https://steamuserimages-a.akamaihd.net/ugc/800989528966498121/835F617EBF07821F44676377E6F9F478289705C1/

https://steamuserimages-a.akamaihd.net/ugc/800989528966500203/8811F43AC98A0E1EC82F69AEDF51E51B24975ED0/

And the next images are from my Level BP.

https://steamuserimages-a.akamaihd.net/ugc/800989528966504133/6143350875D5E868AAE0AAC7EF74BDA714D628BE/

https://steamuserimages-a.akamaihd.net/ugc/800989528966510069/77DA0A56C926C472B4B29AD5744D6794BB626995/

The third image is being called on the Event Begin Play in the Level BP.

On the fourth image I call the Custom Event on Server as I want the Conveyor Belt placed in my Level BP to affect all players as a result. And the server handles it.

As a result of my work, from the Server I get all the Print strings (Hello3, STOP CONVEYOR) but the Client gets only (Hello, Hello2, Hello3) which all get called on the server too. Unfortunately it does not want to call the last Event linked to the Event Dispatcher (Image4).

I also have tried changing this last “Stop Conveyor Belt” Event to being Multicast (Image4). What happens in that case is that:
_ Works well for the server too and the clients also see the changes while playing.
_ The Client calls the Print strings (Hello, Hello2, Hello3 from the Server side too, but STOP CONVEYOR only gets called on the Client and not on the server…). What happens then is that no one see the change in the Level, neither the client nor the server.

I really hope someone will have a solution to my problem as I cannot find any answer online…

Kind regards

One of the problems you have is that the Stop Conveyor Belt function is set to be executed on Server, one of the problems with that is that calls to the server on an actor only work if you own that object, which in the case of the level a client doesn’t.

But to be honest your event flow feels off,
You should never just use a delay and then register to a callback on a character that might or might not be created at that time.
You call on the actor to the server to multicast to everyone, that is fine
but then your level only registers to the locally running character, (character 0 is going to be different characters on client and server) and that registered call is then supposed to do something?

  • I would generally recommend moving the register logic into the begin play of the character
  • Only register on the server
  • Register to all player characters
  • Don’t multicast the commands back (at least in that case it does not seem to be necessary)
  • Multicast the function in the level, or even better make the speeds replicated and just set them on the server

That should result in your clients calling the function on the server, that calls the stop conveyor belt function on the server, which I would recommend set’s replicated speed values which then just get replicated to all clients.

If possible always use replication, prevents some problems, like player joining late

In the first image it is not necessary to have a separate flow for the Authority. If a Server calls a RunOnServer event it turns it into a regular function call. Simply CallTheConveyorBeltStop.

The Level Blueprint is generally never used as it prevents reuse-ability compared to a regular Blueprint. A Conveyor Blueprint and perhaps a Machine manager is all you need to do exactly the same thing without the Level Blueprint. To further decouple it from the Character you could let each player own a MachineController and have the players send RunOnServer events from that.

Thank you GarnerP57 and Lardo Deepdelver for your answers !

I followed your advice and directly handle the speed modifications of the Conveyor Belt from the Character and replicating it. Using a Get All Actors of Class to access the Conveyor Belts directly. Doing the same thing from a Custom Event Rep on Server when the Client calls it.
And I have split my Conveyor Belts into two BPs as I have some for one team and the others for the other team. So that I reach only the necessary ones as I cannot access them separately like I was able to do in the Level BP.