How to call ClientRpc on the scene game object?

For example, let’s say I have a door in my scene that I need to open on all clients after 1 player opened it.

It seems like a very common question, however, I can’t find any information about how to call ClientRpc on the static scene objects. Every piece of information I can find talks about NetworkServer.Spawn() function that you use after you instantiated your GameObject on the server.
But I don’t need to spawn anything, the object is part of the level and it already exists on every client. It might even be static.

interested in the same issue if anyone has a suggestion.
i have my clientrpc in my gamecontroller object (with a network identity)
calling the clientrpc works on the client that is on the host but not on the remote clients.
thanks.

I’m not sure you understand the basic concept of Commands and ClientRPCs. ClientRPC can only be invoked by the server and are always executed on all clients. Commands on the other hand can be invoked by the clients and are actually executed on the server. Note that clients can only send commands to objects they have authority over. This is usually their player object. One object can only have one peer to have authority over that object.

You may want to read through those questions:

Anything a client wants to tell the server is done through commands. The server can in turn execute a client RPC to tell all clients what actually happened. So if you want to have a client to send something to all other clients you have to use a command which is sent to the server and have the server send a clientRPC back to all clients.

thanks for the prompt response @bunny83, i appreciate.
while i don’t pretend to understand everything, i think i got around the basic concept :slight_smile:
in my case, i am indeed trying to have the server execute a function on all clients (not from a client to another). so i guess client rpc is what i need.
my issue is that i want the server to “order” the clients from my gamecontroller gameobject which has a network id but is NOT a prefab. i want to avoid having to make it a spawned player prefab as i set up my scene on its public variables (like canvas text fields, etc.) and would have to redo everything at runtime every time.
so it looks like it’s working on the host (server is able to “order” the local client to execute the function through clientrpc call) but it is not executing the one from the remote client (i double check that the remote client is connected through connections.count.
if i HAVE to go through spawned player prefabs to replace my gamecontroller object, i guess i can but that’d be a shame. i also do not understand why unity forced this limitation.
thanks again for the help!

original question seemed to be closest to my problem. and i don’t think i’m highjacking anything since it was left unanswered since 2016 :slight_smile:

also, you keep repeating the same thing without adressing the question.

regardless, i spent more time reading left and right and found my answer. indeed, commands, clientrpcs and syncvars only work within spawned player objects and not regular gameobjects (even if they have a network identity and behavior). which in my case means i have to re-populate all my UI objects with finds at runtime. hope this can help someone else starting with networking spend less time looking.
@bunny83, thanks for spending the time to answer questions anyway, i see you’re quite active on forums, cheers for that.