Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Sync high number of game objects transforms , is that possible?

Discussion in 'Multiplayer' started by elseforty, Jan 8, 2019.

  1. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    289
    hi,
    i want to build a multiplayer version of this prototype game shown in the video, i'm wondering if it is possible to sync a high number of game objects transforms , around 150 ,
    i have no multiplayer experience, so please excuse me if the question is a stupid,
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Using something like Unet's NetworkTransform wouldn't be very efficient for something like this. I'd probably write something custom for sending the updates for all 150 objects in just a handful of messages.
     
    elseforty likes this.
  3. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    289
    Hi joe
    thanx for the reply,
    can you give me more info about how i will approach this ,
    i thinking of writing the rotation and translation data of all gameObjects in a file in json format
    send that file to a server, the clients take that file and parse the data and pass them to the 150 game objects
    is this correct approach?
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Well it looks like the motion of the objects in your video is fairly fast and you'd need to update your other clients quickly and often (several times per second for every object I'm guessing). Using a text format like json is about the least efficient means of encoding the data sent over the network.

    A Vector3 for position should only require 12 bytes of a message to send (4 bytes for each of the 3 floats), while in text form the amount of data is likely to be considerably higher. Rather than 4 bytes, 127.0069 would be 8 to 16 bytes depending on text encoding, 24 (UTF8 or ASCII) to 48 (UTF16) bytes vs 12 for the whole vector3, plus add in additional characters for the format of json itself. Add in other data like rotation and velocity, and multiply that by 150 objects several times per second, and you're talking about a whole lot of unnecessary bytes used by using a text format. Sending it as a file sounds even less responsive, though I'm not sure what you even mean by this.

    Why aren't you considering having the machine that is generating the data send it directly to the clients instead of bouncing it off this other server, whatever that server is? I mean, your idea may be feasible, just it isn't a fairly efficient way of going about it and may run into performance issues of one kind or another.
     
    Last edited: Jan 11, 2019
  5. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    289
    thanx alot Joe for the detailed answer,
    i didn't know that i can send data between devices only, no server implication,
    anyway if you can give me some hints about how i can achieve this, that would be awesome,
    for the data type maybe if i get this P2P connection working then i can send data in binary format instead,
     
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Well, you could have the server itself run the simulation and update the clients directly, you could do what Unity Multiplayer Service does and use a relay server, you could use a server to set up something called NAT punchthrough.
     
    elseforty likes this.
  7. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    289
    thanx a lot for the info , will look into this