Search Unity

Resolved OverflowException: Reading past the end of the buffer

Discussion in 'Netcode for GameObjects' started by JayCE0, Mar 17, 2022.

  1. JayCE0

    JayCE0

    Joined:
    Sep 2, 2020
    Posts:
    4
    When I run a scene with AI bots inside, Server starts fine but when Client tries to join he will get several errors:

    Code (csharp):
    1. [SceneEventData- Scene Handle Mismatch] serverSceneHandle could not be found in ServerSceneHandleToClientSceneHandle. Using the currently active scene.
    2. [Netcode] NetworkPrefab hash was not found! In-Scene placed NetworkObject soft synchronization failure for Hash: 2147483648!
    3. Failed to spawn NetworkObject for Hash 2147483648.
    4. OverflowException: Reading past the end of the buffer
    When AI bots are disabled prio server starting so they won't be spawned across network client joins just fine.

    I also tried to add just a bunch of empty GameObjects with NetworkObject component attached to them into the scene, and client still couldn't join the game.

    Is there a way how I can manually spawn these objects on each client after he joins, so he won't have to load them in bulk? If there isn't another way of solving this.
     
    Last edited: Mar 18, 2022
  2. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    664
    I've not seen that error before, are there any pre-existing network objects in the scene?

    Out of curiosity have you tried the Unity Transport rather than the UNet one, as a fix was put in to allow spawning larger numbers of network objects, I've just not got around to trying it.
     
  3. JayCE0

    JayCE0

    Joined:
    Sep 2, 2020
    Posts:
    4
    There are pre-existing network objects in the scene, even the AI bots are by default in the scene.

    I'm actually using Unity Transport for several months now. I used to have issues with some NetworkObjects code being run before they were spawned in the scene, which was working just fine in the editor but after I build the game it completely broke. I did fix all of this issues inside scripts as well as cleaned my whole scene from any unnecessary NetworkObjects so in the end the scene looked cleaner than my own bathroom, yet the problem still remained without me having any clue what to do.

    Then I decided to just delete the whole Library folder and let it import from scratch and it fixed all of the issues..
     
    NelsonChristensen likes this.
  4. unnanego

    unnanego

    Joined:
    May 8, 2018
    Posts:
    199
    I'm using parallel sync and having the same problem. Same in the build. Not using bots...
     
  5. mrstruijk

    mrstruijk

    Joined:
    Jan 24, 2018
    Posts:
    52
    Did you manage to solve it? Does it have to do with ParrelSync itself? In Tarodev's video he sets the profile with the ParrelSync's client name, maybe that helps?
     
  6. mrstruijk

    mrstruijk

    Joined:
    Jan 24, 2018
    Posts:
    52
    I had the same thing! I made some mistakes early on by creating some weird nested NetworkObjects, which didn't work. Then, when I actually cleaned up my act, and made sure there were only NetworkObjects at the root of any spawned GameObject, I still had Android LogCat bombard me with errors like:
    Code (CSharp):
    1. Error Unity [Netcode] NetworkPrefab hash was not found! In-Scene placed NetworkObject soft synchronization failure for Hash xxxxxx
    Rebuilding the Library folder solved it!
     
  7. csiro_rmc3

    csiro_rmc3

    Joined:
    Jun 8, 2014
    Posts:
    14
    Thanks everyone, I ran into this error today and this post helped me solve my issue - however it ended up being a bit different.

    Exactly the same error pattern and I too at one point had incorrectly put a NetworkObject as a child of another NetworkObject - clearing the cache didn't resolve my issue though.

    My usage pattern is I have static NetworkObjects created in the scene hierarchy and I was selectively hiding and showing at runtime using the SetActive flag. This was causing the client/server to get out of sync and causing the errors. I changed the pattern to leave the root object with the NetworkObject component always active and only set the active flags for the child objects instead - keeping the client/server in sync and resolving the error.
     
  8. burgerandfries43

    burgerandfries43

    Joined:
    Jan 23, 2021
    Posts:
    8
    For me this error seems to have spawned from a NetworkVariable