Search Unity

How to properly load client into scene when EnableSceneManagement is disabled?

Discussion in 'Netcode for GameObjects' started by ClearDark, May 13, 2022.

  1. ClearDark

    ClearDark

    Joined:
    Aug 25, 2013
    Posts:
    14
    Hello,

    Continuing my efforts, im trying to load clients into the main "game" scene only when they have done a few selections prior.

    I have disabled EnableSceneManagement from the NetworkManager object. I start the server and load it into the game scene instantly using the MonoBehavior LoadScene method,

    Then, I start a client, the client then connects to the server and loads into the scene using LoadScene. I can see the client in the server game view, the client can move around the scene fine, however the movement does not sync back to the server. I'm using the provided ClientNetworkTransform for syncing transform position.

    Note that if using EnableSceneManagement set to true, the client loads into the main scene automatically after joining the server, and everything is working fine. However i'd like to prevent the client from loading directly into the "game" scene and let the client make some choices before.

    Thanks for the help!
     
  2. CosmoM

    CosmoM

    Joined:
    Oct 31, 2015
    Posts:
    204
    It sounds like the problem might be that you're using the non-networked scene manager. Even when EnableSceneManagement is set to false, I believe you should still be using
    NetworkManager.Singleton.SceneManager.LoadScene(...)
    to change scenes.
     
  3. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    664
    I was curious to try this as I've been using the UnityEngine SceneManager, when I tried the above I got an exception suggesting to re-enable scene management.

    ClearDark there's a lot to take into consideration when handling scene management yourself. I haven't used ClientNetworkTransform but does the client object have a NetworkObjectId and does it match that of the server's object? Is this the Player object and is it spawned automatically?
     
  4. ClearDark

    ClearDark

    Joined:
    Aug 25, 2013
    Posts:
    14
    I tried loading the scenes with NetworkManager and it throws an exception that only the server can use this function.

    The client object has NetworkObjectId and everything matches perfectly. I wish there was some sort of an example or documentation on how to handle scene management without the NetworkManager SceneManager.

    I keep trying different approaches but so far no luck. I cannot get a controllable player without the EnableSceneManagement set to true no matter what I try.
     
  5. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    664
    I did a quick test with ClientNetworkTransform and changed the client's transform values in the editor and they were correctly updated on the server. You'll probably have to share your project to gain an understanding of why it's not working for you.