Multiplayer Event Dispatcher


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.

And the next images are from my Level BP.

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.