What is the proper way of replication a non-owned actor?

I have a problem with how to properly replicate an actor that is directly placed in game from editor. For example it is
street light that i want to toggle using characters. From what i discovered i can’t call RPC method on the Server directly from this street light, because I’m getting this kind of warning: “No owning connection for actor …”. From what i understand this is because my client player controller is not the owner of this actor. So what is the proper way to resolve this kind of problem in UE4?

The problem is as the error says, you need to make sure that the actor is owned by something that can replicate.

A simple way would be to have the street light be spawned by the GameMode when the game is starting so the street light has a owning connection with the GameMode. If the street light is set to replicates, you should be able to interact with any of the pawns in the map.

Ok, but what if I want this street light to be placed manually in editor so I can easily manipulate this without changing the position of it in code?

I would create a “street light spawner” that has the orientation and position of where you want to put the street light (what you place when in the editor) that the GameMode (or whatever) can then use to spawn the Street light Actor at.

I understand that there is no better way to solve this kind of problem?

This is best way that I have done in the past. You could however try a few things, such as having one of the clients “own” the street light so it can replicate back and forth.

You could also try setting the owner to itself (from the server side), see if that does anything.

Realistically though, in order for the replication calls to succeed, they need to have a owning actor and be coming from an actor that is replicated. I have found the most straight forward way to achieve both of these is to spawn the actors during run time, from the server side, and make sure the owning actor can replicate.

I think you are looking for NetMulticast

NetMulticasts execute the behaviour on the server and all connected clients, even if the Actor is not owned. You only have to fire the NetMulticast from the server for this to work.

You can read more about that here

I’ve posted a solution to this here. Seems to be a common question.

Well, I posted there too, just to say that NetMulticasts work just fine.