Search Unity

Question MLAPI Spawned Object Limit?

Discussion in 'Multiplayer' started by flyQuixote, Sep 19, 2021.

  1. flyQuixote


    Jun 23, 2013
    Hello, first time posting here in a while.

    I recently changed my project to use MLAPI instead of Mirror and have run into a few issues related to spawned objects. Spawning objects in MLAPI is causing issues:
    1. Spawning objects too quickly leads to crashing
      • I'm mitigating this by spawning objects at a limited rate per second, that way the network has time to catchup to the number of spawned objects.
    2. Spawned objects will not despawn properly when the scene is unloaded (do I have to manually unload obejcts before switching scenes?)
      • They will remain in the client scene as objects even after the scene is unloaded. The objects will actually join the next loaded scene.
      • There is sometimes a message along the lines of "Tried to destroy object with id X but that object does not exist"
    3. Clients will crash when joining a game with a couple hundred network objects spawned with the message "Max message size cannot be greater than 65527"
      • This one the client cannot connect and just shows an error message. Are all the spawned objects being sent at once-- is there a setting I can use to allow the spawned objects to be loaded at a slower rate?
      • I can prespawn most objects and limit the number of dynamically spawned objects but this makes the scenes much larger than they would otherwise be.
    4. When joining a scene with about 100 spawned objects, the load time for the scene can be greater than 10-15 seconds.
      • There isn't an error associated with this one, but I'm curious as to what I can do to mitigate this issue.
    My project is open source here nicholas-maltbie/FallingParkour: Multiplayer racing game made with Unity ( Any feedback or advice is appreciated, I wasn't able to find these errors in the documentation or FAQ.

    All of these issues I have a temporary workaround for, but I would like to know the proper way to handle these issues or if there is something like a spawn limit for the game. I read something about channels being able to fragment data, since each of my network objects only have at most a couple hundred bytes associated with them, should I put these objects into their own separate "fragmented" channel?

    I know the project is in alpha and this might be something patched soon. I may want to switch back to Mirror until MLAPI is in a more stable state. Whatever works best, I like using new tech though and it's been fun learning MLAPI.