How to transfer a game object with photon view from one room to another?


For our project, we are trying to send the player to a room once they collider on a wall, and carrying over their avatar spawned in this room with them to the next room. Our implementation was to transfer the ownership of photon view component and add the new one, this work fine for the master client, however, it caused error for other client where the controller on them are null, and they lose control of the avatar. Is there any solution you would suggest to transfer the avatar to a different room? Thanks!


  • Dibbie

    I dont think there is any easy way to do exactly that, without any kind of plugins and authentication or database, once you leave a room, Photon doesnt really have a native way to keep track of that player, so theres no where to really store data about the player, even if you are able to keep a copy of the PhotonView, its given a "View ID" when it was created, and that does not persist outside a room - though why do you want to do this? Are you trying to load cosmetics of a player on your menu/outside your "gameplay" scenes, or something else?

    Rather than try to transfer over a entire networked object, you could keep a reference to just the data you need, and rebuild that data on the network when you need to, if for example, you have a "GameManager" that handles spawning connected players in a room, you could send whatever data it needs to know about a player, and create a new avatar for them while also applying the desired changes before enabling any scripts that gives the player control of that object