Search Unity

An issue with ClientNetworkTransform related to scene loading? Need help

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

  1. ClearDark

    ClearDark

    Joined:
    Aug 25, 2013
    Posts:
    14
    Hello,

    I've set up a single scene with a NetworkManager, my player character has a ClientNetworkTransform, spawning clients in the game, everything seems to work fine, everything is synched to perfection.

    The problem started when I tried to separate the "game" scene from the menu scene, setting up like this:

    Main menu scene (contains the NetworkManager),
    Game scene

    Player loads into Main menu scene, clicks a few buttons and "joins" the server, I have a function on the Player controller (NetworkBehavior) :
    Code (CSharp):
    1. public override void OnNetworkSpawn()
    2.     {
    3.         if (IsOwner && IsClient)
    4.         {
    5.             NetworkManager.Singleton.SceneManager.LoadScene("GameScene", UnityEngine.SceneManagement.LoadSceneMode.Single);
    6.         }
    7.     }
    Clients do load into the game scene, you can see them around, but no movement is synched across clients. I can even see the animations sync properly since the Network variables do sync, but the clients can't see eachother moving.

    What am I missing here?

    Thanks alot!
     
  2. luke-unity

    luke-unity

    Joined:
    Sep 30, 2020
    Posts:
    306
    When using netcode you are not supposed to manually load scenes like that. The NetworkSceneManager will automatically switch the client to the same scene so as long as your serve is running the Game scene it should just work.
     
  3. ClearDark

    ClearDark

    Joined:
    Aug 25, 2013
    Posts:
    14
    Thank you, I called it once on the server only and it works perfectly fine.