- Home /
Remote Procedure Calls in unity with Unet?
Guys I am bit confused about these calls. I know the basic understanding of it but can someone please explain them a bit. Following are the calls I am confused about. [Client] [Server] [ClientRpc] [Server]
you mentioned Server twice. I just explain them all.
[Server]: can be applied to methods (not NetworkBehaviour callbacks like Update) as a sanity check. when accidentally called on a client instance, an error is thrown.
[Client]: same thing, just the opposite scenario.
[ClientRPC]: implies the server attribute, because it must be called on the server and is then send over network and executed on the clients.
[Command]: opposite scenario with the restriction of only player objects or NetworkIdentities with client authority can call them to send a call to the server. Implies the Server attribute. [ServerCallback][ClientCallback]: restrict NetworkBehaviour calls like Update to be executed only on the corresponding connection type. Useful for Updates that should run exclusively on clients for example.
Great @hexagonlus basically it means that server and client are for self satisfaction that it only runs on server and client side respectively?
Yes, that's right. But they don't keep you from calling them on the wrong $$anonymous$$m, just throw an error then so you know you messed up at some point.
Answer by arbazgillani · Sep 28, 2018 at 09:49 AM
I want to clear things a bit. I was taking em wrong. Every Script that is networked and is on server end behaves as a server part. All players that are Spawned over a network has a server part and a client part. I was misunderstood about that. So [Server] Command runs all functions at server side [Client] on all client instance of that object or script and [Command] is a call to server from the client and [ClientRpc] is a call to all clients of that object from the server.