Search Unity

Synchronizing the state of scene objects

Discussion in 'Multiplayer' started by Aupuma, Apr 3, 2018.

  1. Aupuma

    Aupuma

    Joined:
    Feb 15, 2017
    Posts:
    42
    Hi, I'm new to UNet and I'm trying to send the state of scene objects to the server and then the clients.

    • There are 5 objects and one ObjectManager that are already placed in the scene and have some references to other objects.
    • When one of these objects is found, the rest of the players will be told that it has been found.
    • When all objects are found, a new object will show up in the scene.

    I've been dealing with the problem, trying different solutions. When an object is detected, I call a command function in a PlayerConnection script that updates the state of the object in all the clients with a syncvar and adds 1 to the object count (also a syncvar) in the ObjectManager.

    Is there a better way to do this? Couldn't I send the state of the object to the object Manager and then its state is synchronised over the network without need of a PlayerConnection script?

    Also I'm trying to use a SyncVar Hook so when an object is detected, all the players update a text in their UI with the number of objects but it does not work.