Network Player Destroyed after switching from matchmaking scene to Game scene!!

Hello ,

I’m building a simple multiplayer game having :
LoadingScene => to connect to photon server.
LobbyScene => GUI where I create the rooms ( room size and roomName fields) and button create and join room.
MatchMakingScene => where I spawn players (instantiated using photon) and once the room is full I photonNetwork.Load(the next level) AKA the actual game scene say GameScene.

The problem is once in the GameScene , the players are destroyed at the beginning. !!
PUN-instantiated ‘Test(Clone)’ got destroyed by engine. This is OK when loading levels. Otherwise use:

I tried using DontDestroyOnLoad , the player survives switching scene from matchmakingScene to gameScene
but I have no control on it , null reference everywhere)

I have Two questions please :

  • Is there a clean way to keep player between scenes without issues?
  • What is the best practice : is it to keep player between scenes or instantiate players in each scene , especially that in a future scene the spawn position will be completely different.?

I hope the scenario is clear and Im ready if more details are needed .
Thanks in advance.

I think you need to start differentiating between a player and an avatar. Think of a player as a network only placeholder for a player in a room, unrelated to the scene. So you have a player with a nickname that joins a room. Then you can load any scene you want for all those players in that room. After the scene change, based on the game specifics that will be in that game/scene, you then spawn in the player’s Avatar. That is the actual gameobject with the photon view that is owned by a player.

So, to answer you, keeping in mind you said “simple multiplayer game”:

  1. I would not do this.
  2. I think you should instantiate the player’s avatar in each scene.