Skip to main content

Messaging System and RPCs

Community Contribution

There is a Video Tutorial covering some of the concepts covered in this page here

The MLAPI has two parts to its messaging system: RPC messages and Custom Messages. Both types have sub-types that change their behaviour, functionality, and performance.

RPC Messages#

The multiplayer framework provides two main network constructs to execute logic on either server-side or client-side: ServerRpc and ClientRpc. This concept is often called Remote Procedure Call (RPC) and has wide adoption across the industry.

info

For more information see the wikipedia entry on Remote Procedure Call's.

RPCs#

Unity MLAPI provides a refactored Remote Procedure Call (RPC) which provides increased performance, significantly reduced boilerplate code, and extensibility for future-proofed code. MLAPI RPC includes ServerRpc and ClientRpc to execute logic on the server and client-side. This provides a single performant unified RPC solution, replacing previous MLAPI Convenience and Performance RPC.

See the following information:

There is also some additional information on RPC's and some usage examples on the following pages:

Migration and Compatibility

See RPC Migration and Compatibility for more information on updates, cross-compatibility, and deprecated methods for Unity RPC.

RPC method calls#

A typical framework user (Unity developer) can declare multiple RPCs under a NetworkBehaviour and inbound/outbound RPC calls will be replicated as a part of its replication in a network frame.

A method turned into an RPC is no longer a regular method, it will have its own implications on direct calls and in the network pipeline. See Execution Table.

Serialization Types and RPCs#

Instances of Serializable Types are passed into an RPC as parameters and are serialized and replicated to the remote side.

See Serialization for more information.

Custom Messages#

See Custom Messages for information on Custom Messages.