Search code examples
c#unity-game-engineunity3d-unet

Unity Networking synchronization via SyncVar


I am writing a Unity App, which connects two mobile divices using Unity Networking. One is acting as a Master (the host) and the other one as a Slave (Client). The Application should synchronously take photos from each device.

For now I am using SyncVars for achieving this. Every ten frames, the server changes a SyncVar, the onChange method of this variable is then called and both Host and Client take the photo and send it back to the Host using [Command] methods.

I am new to Unity Networking so this is my first implementation and I guess its not the best way solving this Problem.

Is there any other syncronization in UNET for this UseCase?

Thanks in advance, Mirko


Solution

  • Try using an RPC Method (is sent to every Client from the Server) for taking the pictures. As the Server also acts as client itself, both should start the RPC Method (alsmost) synchronious. When both devices are in the same network, there should not be such a high latency taking the picture on the client.