Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Maximum buffer size not in documentation?

Discussion in 'Multiplayer' started by BIT-64, Apr 9, 2024.

  1. BIT-64

    BIT-64

    Joined:
    Apr 29, 2017
    Posts:
    43
    Hello,

    I am using netcode for gameobjects, the unity transport layer. It seems like the maximum buffer size is not mentioned in the documentation. Does anyone know what it is?

    Thank you
     
  2. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    Which setting exactly are you referring to? The tooltips on each value should provide a good explanation of what each setting does. Basically maximum payload size is the largest (unreliable) payload that can be sent through the transport, and maximum packet queue size is the maximum number of packets that can be received or sent in a single frame. Both values are best left at their default. In both cases, you will get errors or warnings if you hit conditions that warrant increasing the values. But this is generally not required for the types of games Netcode for GameObjects is meant for.
     
  3. BIT-64

    BIT-64

    Joined:
    Apr 29, 2017
    Posts:
    43
    In my case I am using an Rpc for it's reliable nature, I am sending a large array of 200x200(byte), I was able to send/receive in a test, I am not sure why because this would be quite large in bytes, does the rpc automatically split it in many pieces, never exceeding the info from here? upload_2024-4-9_12-20-34.png
     
  4. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    Yes, because RPCs are reliable by default, they are automatically split in smaller pieces. The maximum payload size setting has no effect on reliable traffic (including RPCs) and for this kind of traffic there is basically no limit to the size of the data that you can send. (Well, there is a limit, but it's in the megabytes range and I'd recommend against sending payloads that large using Netcode. At that point you'd be in file transfer territory and there are dedicated protocols that are better suited for that.)
     
    CodeSmile likes this.
  5. BIT-64

    BIT-64

    Joined:
    Apr 29, 2017
    Posts:
    43
    Where can I find this information in the documentation, thank you
     
  6. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    I don't believe that these differences between reliable and unreliable messages for the maximum payload size setting are documented, except perhaps in some changelog entries. Generally, this is not a setting that users have to worry about. In 99.9% of cases, it needs not be modified. (In fact, in hindsight I should have never exposed it.)
     
  7. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,636
    While that's "only" 40k and should go through, there's always the option to run GZipStream over your array and possibly compress it down to a much smaller size. Which would be good practice anyway unless you know the data is hardly compressible.

    And if you don't use the full 0-255 range of values, you could compress it even further into a BitArray (eg 6 bits per entry rather than 8 if the range is 0-63), and then Gzip that.