Search Unity

Max Payload Size Unity Transport

Discussion in 'Unity Transport' started by DavidP145, Jul 1, 2022.

  1. DavidP145

    DavidP145

    Joined:
    Mar 17, 2022
    Posts:
    1
    Hi, I'm working on a multiplayer game. It's been going well until I've had to increase the Max Payload Size in my Unity Transport component.

    I think by default the max payload is ~6000 but via trial and error I have discovered that the state that my game is in right now the max payload needs to be <~61,000.

    screenshot2.jpg

    So that bring me to my questions:

    1. What is Max Payload and What influences its value?
    2. What is a good Max Payload value?

    Thank you
     
    LittleCoinCoin likes this.
  2. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    The maximum payload size is the length of the largest single message that can be sent through the transport. You may think of it as the maximum size of a single "packet" (although the transport may elect to fragment the payload into multiple actual network packets). We require this to be configured upfront to allocate buffers at initialization (we want to avoid dynamically allocating memory at runtime).

    What influences its value is what the largest message Netcode for GameObjects (NGO) can end up sending through the transport. By far the largest message NGO will send is the message with the current world state it sends to newly-connected clients (other messages following this one are typically pretty small). The size of this message is influenced by how many network objects/variables/transforms you have in your scene.

    The simple answer is whatever value makes your game work correctly.

    The more complex answer is that it depends on how many objects/variables/transforms are being synced over the network. Unfortunately we don't have any guidelines currently to map a number of objects to a maximum payload size (e.g. 100 network objects require 50KB payload size or something like that), so finding the ideal value involves some trial and error.

    Note also that aside from using slightly more memory than necessary, there shouldn't be any issues with setting this value too high. Erring on the side of having a value that's higher than strictly required might be a good idea.
     
    trombonaut and DavidP145 like this.