Actions from 2 blueprints in Multiplayer

Hey, I’m looking to turn on the lights in my map from a button. Of course, I want them to turn on for all players.

In the Gamemode of the map, I created a TurnOnElectricity event that gets all the lights of the map, then I use setVisibility to turn on the lights.

Then I created an event in the Playercontroller of the map called TurnOnAllLights. I created an interface to the gamemode to avoid the cast. Then I call the function I created before, TurnOnElectricity. This event is executed on owning client and reliable.

Then, I created a button actor with a box collision, and when the box is overlapped, I also have an interface for the playercontroller. So I just called the function from the playercontroller.

So it works for the host, but it doesn’t work for the client. Also, I have the following error:

I’m pretty new to multiplayer. I’m trying to use the appropriate blueprint for this, but without success.

Try using GameState instead of GameMode. As @chrudimer mentioned, GameMode only exists on the server, whereas GameState exists on the server and on all the clients, so you can run a NetMulticast function on the server, and it will be executed on the server and all the clients.

Hi, GameMode only exists on the server, clients cannot access it. How is the overlap event in your third image triggered? If all the things taking part in that overlap are replicated the overlap should also happen on the server, then there would be no need for any replication and you can just do the logic on the server.

I created an interface to the gamemode
to avoid the cast

What you have done there has all the drawbacks of casting. If you want to use an interface instead of casting, then you would just use GetGameMode → call interface function on that reference. Not GetGameMode → interface function that returns reference to MainWorldGM → call function of MainWorldGM. AFAIK the whole reason of interface vs casting is that you do not need to know about the object you’re calling the function on.

In your case you again have a hard object reference to MainWorldGM (which is no problem since the game mode is always loaded in memory. It will get a problem though if your interface references more than one game mode, e. g. if you switch out the game mode and keep the interface function that returns the old one, then now both will be loaded in memory) and if you would want to switch out the game mode, you would need to go through all the code where you use your interface and make adjustments (which is a problem if you’re planning on ever switching out the game mode. And ofc same for the player controller).