Peer-to-peer allows sending direct messages to players instead of passing through the Relay Server.


Peer To Peer works only in Relay mode since other modes ( Embedded and Authoritative ) there is no make sense in having direct communication between peers.


But how ObjectNet work with Peer to Peer?


In relay mode, one player is selected to be the host of the match, this means that all logic shall run on this player. What ObjectNet will do is check if this player is visible outside ( public IP or NAT Traversal supported by the router ) and communicate directly with this player instead of sending it to the Relay server.


Not only unreliable messages will take this route, but reliable messages will still be sent using the Relay server, this has a significant reduction of traffic messages and as a consequence, shall reduce the needed traffic on your game.


Another good collateral effect of peer-to-peer use is the reduction of latency since messages will be sent directly to the host player instead of passing through the Relay server.


The following drawing illustrates how Lobbies on Peer to Peer works.



In this scenario, Player1 is the host of the match, and Player2, Player3, and Player4 will be notified that Player1 is network visible and try to send unreliable messages directly to Player1.


This may provide an amazing reduction of your costs with bandwidth if you are hosting your game into a hosting service such as Azure, Amazon, or any other.


You can Enable Peer to Peer by checking the option on NetworkManager.