Hello!
I am using Unity 2019.3.4 and Photon PUN 2 version 2.26.
I have a very simple scenario with only one room all players connect to. I have set PhotonNetwork.AutomaticallySyncScene = true;
So that when th emaster client calls PhotonNetwork.LoadLevel("MyScene");
all other clients load the new level too.
Each client spawns a player GameObject when they connect. The master client drops an additional GameObject in each scene, calling PhotonNetwork.Instantiate()
and at the right time loads a new scene for all clients. There only three scenes.
I am assuming that everytime the master client loads a new scene, all networked objects previously instantiated with PhotonNetwork.Instantiate()
are destroyed and it seems to be the case.
So far so good.
However, if a client (not the master) crashes, when I restart it, it joins the room and loads the right scene (because of PhotonNetwork.AutomaticallySyncScene = true;
) but it also locally re-spawns all networked objects which were created in previous scenes!
Why does that happen? I thought all networked objects spawned in a scene were destroyed when a new scene is loaded. is that not the case?
The only way I found to avoid this issue is to call PhotonNetwork.DestroyAll();
before loading a new scene. Is that what I am supposed to do?
Many thanks
Michele