Comment on page
Networking attributes are added to member functions of Network Behaviour scripts, to make them run on either the client or server.
These attributes can be used for Unity game loop methods like Start or Update, as well as other implemented methods.
NOTE: when using abstract or virtual methods the Attributes need to be applied to the override methods too.
- [Server] Only a server can call the method (throws a warning when called on a client).
- [ServerCallback] Same as Server but does not throw a warning when called on client.
- [Client] Only a Client can call the method (throws a warning when called on the server).
- [ClientCallback] Same as Client but does not throw a warning when called on server.
- [TargetRpc] This is an attribute that can be put on methods of Network Behaviour classes to allow them to be invoked on clients from a server. Unlike the ClientRpc attribute, these functions are invoked on one individual target client, not all of the ready clients. See also: Remote Actions.
- [SyncVar] SyncVars are used to synchronize a variable from the server to all clients automatically. Don't assign them from a client, it's pointless. Don't let them be null, you will get errors. You can use int, long, float, string, Vector3 etc. (all simple types) and Network Identity and game object if the game object has a Network Identity attached to it. You can use SyncVar Hooks to run code on clients when they receive updates from the server.