How would you recreate a light switch and light in Blueprints?

Newbie here, thank you for your patience.

I’ve watched the official Blueprint tutorials covering enabling/disabling/handling input, having blueprints communicate to each other via custom events and event dispatchers, and networking (variable and function replication).

I’ve tried to combine it all to make a [conceptually] simple light switch blueprint and lamp blueprint that communicate to each other (light switch sends a boolean to lamp light that sets visiblility), and also works in a client/server multiplayer environment.

The light switch and lamp work fine in single-player, but multiplayer is only halfway working - The server can switch the light on and off just fine, and it even shows in the client, but the client doesn’t want to switch on that lamp.

My blueprints are extremely messy from inserting Print nodes all over to try and figure out where the breakdown is, so forgive me for leaving those out for now; I will post them tomorrow after work, and after I’ve cleaned them up to be more viewable/readable.

Here are some screenshots of the behavior I’ve got working so far:

[Light Off]

[Server Toggles Light On - Replicated to Client Succesfully]

If I try to use the Client to toggle that light switch, nothing happens.

So, what would you do to get a Client to communicate properly to the Server, telling it “I am toggling this light switch’s boolean, so you need to change the boolean in that lamp to match, which would turn on that light source”

I’m probably way over-thinking this, and/or I’m missing a proper setting of Run on Server/Run on Owning Client/Multicast.

How would you go about making an interactable light switch blueprint and lamp blueprint work as expected and sync across server and clients?

Thanks in advance!

UPDATE: Some research leads me to think that I need to make the client “own” the light switch in order to make sure the RPC event in the light switch blueprint is functional, or perhaps make the player’s character be the one to send out an RPC instead of the light switch itself. Will try more things after work.

Hey FaceToKeyboard,

Without seeing your blueprint setups, it’s a little difficult to help pinpoint what may be going on–if you wanted to dig in a little more yourself more before posting your blueprint screenshots, take a look at this post from the forums: New Blueprint Networking Tutorial Videos Posted - Announcements - Epic Developer Community Forums

That has a list of blueprint networking tutorials that may offer some insight into your issue. We don’t have the maps he’s using the in the tutorials available publicly just yet, so if you are still having trouble getting this working just reply back with your blueprint screenshots and we’ll be glad to take a look with you.

Thanks!

-Steve

I’ve cleaned up my relevant blueprints and boiled them down to the core of how I’m trying to get things working.

Here are the screenshots of my light switch, lamp, and level blueprints.

The Set with Notify function for the boolean simply toggles the light on and off.

When using the Server player, the light visibility does properly replicate to the client.

The light visibility toggle does not work when using the client.

I appreciate the help!

Hey FaceToKeyboard,

I’m just checking in to make sure this issue was resolved. Are you still having trouble with it?

Hello i also have the same problem. Since no one have posted the solution i want to reopen this cuestion. Thank you very much.

After few researching i found that this must be releated to the owner. The light is owned by the server so the client dont replicates over the network. But I really donde know how resolve this.

Hello monovdd,

What is important to know is that the requests to the server can only be made by the owner, so having function replication in the light switch actor or the lamp actor is incorrect - actors in the level are owned by the server.

What you need to do is make a request to the server using either the pawn that is possessed by the client, or the client’s player controller. Wherever you create your replicated Custom Event/function, you need to call it from that pawn or player controller.

Hope this helps!

Could you make an example? Im really lost with this issue.

This is what i have on the Blueprint of the character where all other function like movement of the character occur.

I call form that first function with a blueprint interface another function on the swith light blueprint

And then I use the variable On Rep for turning the light on.

The result is that the client can turn the light but the effect is no trasmited over the network only when the server turn the light on the effect is trasmited over the net.

I really need your help to understand those localization issues. Im really newie with this engine.

I am at work at the moment, so I will be able to upload an example once I’m home.

For now, I will say that you are very close, but have the Call Interface → Server Call backwards: It should be Server Call → Call Interface.

In your Blueprint of your Character, you should call a Run On Server event, such as “Rama (Verdadero)” → “Call Inteface (Run on Server)”

then, also in your Character Blueprint,

“Custom Event: Call Interface (Run on Server)” → “Oninteraction User”

This way, the character will make the call to the server, then the server will call the interface, which will allow the event to fire on all clients.

Hope this helps; I will help again at home if you are still having trouble.

I’m pretty lost right now hahahaha. If you could show me an example… you will help me so much. I did what you told me with the custom event but it didnt work… I sure that im doing someting wrong.

You was right. I found the solution here: Blueprint RPC for non owner - Blueprint - Epic Developer Community Forums

Now it works fine. =D Thank you very much.