Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Max Payload Size Unity Transport

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

  1. DavidP145


    Mar 17, 2022
    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.


    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


    Unity Technologies

    Jul 19, 2021
    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.
    DavidP145 likes this.