

Assuming that all computers started from the same initial game state, this would ensure that all games played out identically across computers. Once all the computers had communicated their next move to all the other computers, each computer carried out the moves after which it was time for the next turn. The game consisted of “turns” and in each turn a computer could choose from a limited number of “moves”. Initially, each computer exchanged game information with each of the other computers in a star topology. A brief history of networkingīefore diving into the networking solution that Unity offers, lets briefly look at the history of multiplayer games and their networking solutions. lossy connections and the handling of lost dataįor real time games the above problems are especially relevant and if not handled correctly will result in players experiencing “lag”.differing network latency between players (round trip time), and differences in the variation thereof (jitter).players with differing connection speeds.players playing on differing hardware platforms (cpu/memory), such as pcs and mobiles.This will require the handling of problems such as: Using RPCsĪ function must be marked as an RPC before it can be invoked remotely.If you are planning to make a multiplayer game in Unity, be it two player turn based or massive multiplayer online, you will have to implement some sort of networking solution capable of ensuring that all players share the same consistent world view. A client could in turn send an RPC only to the server to specify starting options, such as the color they prefer or the items they have bought. A server could send an RPC to a particular client to initialize the player right after they connect, for example, to assign them their player number, spawn location, team color, etc. A client of a particular player could send RPC calls to everyone to signal that they picked up an item. For example, a server for a game which only starts after four clients have connected could send an RPC call to all clients as soon as the fourth one connects, thus starting the game. RPC calls are usually used to execute some event on all clients in the game or pass event information specifically between two parties, but you can be creative and use them however you like. For example, you can easily invoke the RPC function on all connected machines, on the server alone, on all clients but the one sending the RPC call or on a specific client. There are several possible RPC call modes to cover all common use cases. Unlike a normal function call, an RPC needs an additional parameter to denote the recipients of the RPC request. You should keep parameters to a minimum in order to get the best performance. Invoking an RPC is similar to calling a normal function and almost as easy but there are some important differences to understand.Īn RPC call can have as many parameters as you like but the network bandwidth involved will increase with the number and size of parameters. Remote Procedure Calls (RPCs) let you call functions on a remote machine. This information is for legacy projects using the old networking system.) (For new projects, you should use the new networking system introduced in 5.1.
