Search Unity

Bug Client can't reconnect

Discussion in 'Multiplayer' started by cunibon, May 21, 2022.

  1. cunibon

    cunibon

    Joined:
    May 6, 2020
    Posts:
    7
    Hello,
    I have a problem with Netcode for gameobjects.
    When a client first joins a Server everything works fine, but if he leaves and tries to reconnect "NetworkManager.Singleton.ConnectedClientsIds.Count" will say there a 2 clients but the client wont be taken to the new scene as he normaly would, instead he stays in the main scene. I also get an error stating:
    "MissingReferenceException: The object of type 'NetworkObject' has been destroyed but you are still trying to access it."
    but all the code executet befor is also in netcode so I dont think it is my code. I have attached a file with that error and everything that follows after that.
    When I restart the host the client can join again.
    This really confuses me as there isnt even a player prefab or anything i spawn. All Objects are spawned and owned by the host. I also attached a file with my NetworkManager settings.
    When I get thrown to the main menu there would be 2 NetworkManager so I attached this script:

        static NetworkManagerSingleton instance;

    public void Awake()
    {
    if(instance == null)
    instance = this;
    else
    {
    Destroy(gameObject);
    return;
    }

    DontDestroyOnLoad(gameObject);
    }


    I use "NetworkManager.Singleton.Shutdown();" to close the previous connection.
    This is really messing things up, if you have any idea it would be great. I am probably just blind to something obvious.
     

    Attached Files:

  2. cunibon

    cunibon

    Joined:
    May 6, 2020
    Posts:
    7
    Just to clarify I believe this is a bug as all the errors point to netcode not my scripts, but my debug knowledge is also quite limited.
     
  3. lavagoatGG

    lavagoatGG

    Joined:
    Apr 16, 2022
    Posts:
    229
    Hello @cunibon,
    have you found a solution for this?