Player objects lose isLocalPlayer after using ServerChangeScene()

Basically the title. Everything works perfect when the players join and they all have their individual isLocalPlayer, but when I use ServerChangeScene() they lose it. They change the scene fine, but they don’t have control over their player objects anymore. I’m using DontDestroyOnLoad() to keep the player objects persistent. Should I be keeping them persistent a different way?

I’ve been struggling with this for a little bit now and it’s the only thing stopping me from implementing the multiplayer side of my game.

I have tried to reproduce this issue with no success using:

    void Start()
    {
        DontDestroyOnLoad(gameObject);
    }

    void Update ()
    {
        if(Input.GetKeyDown(KeyCode.Space))
        {
            Debug.Log("isLocalPlayer " + isLocalPlayer);
        }

        if(Input.GetKeyDown(KeyCode.Tab))
        {
            Debug.Log("Changing scene "+isServer);
            if(isServer)
            {
                NetworkManager.singleton.ServerChangeScene("Scene2");
            }
        }
    }

Could you file a bug report with a project for this issue?
If you do file a bug, please send me the case ID or write in the description to assign the case to Gintautas.

Thanks!

Thanks for your reply!

I double checked and it turns out that I never used DontDestroyOnLoad(), though I was nearly certain I was using it. Thanks for making me double check my code and add it. Works great now!

1 Like