How to clear out a room or destroy?
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
How to clear out a room or destroy?
dshewmaker
2014-03-23 19:10:22
Hello,
I can't find anywhere how to reset a room. opposite of PhotonNetwork.JoinRandomRoom() What method to close / destroy the room and create a new one?
Thanks, Dennis
Comments
You leave a room and the others in it can keep using it. You can create or join another.
PhotonNetwork.leave();
dshewmaker
2014-05-19 23:19:19
Back to this topic... I can't find a good way to destroy the room completely and recreate it to force all players to start over from the master client.
I run this: PhotonNetwork.DestroyAll(); PhotonNetwork.LeaveRoom();
but rejoining player objects still show up... I can't find a PhotonNetwork.DestroyRoom(); or equivalent.
I don't want other to keep using it.
Question is: How to destroy a room, or reset to start state a room?
Thanks, Dennis
There is no DestroyRoom() and I think DestroyAll() only works locally (in a hurry, not looking it up now, sorry).
There will be all kinds of tiny issues due to latency and concurrency that you don't expect now and that will happen very rarely and will be hard to debug. The best network code is simple network code. You should possibly just close the room and make it invisible and use another. The idea about the rooms is that they are disposable and work only for a small number of players. If you use a single room name "important room" for everything and continuously, then "important room" will become too small for a successful game maybe.
Can you elaborate what you plan to achieve and we give feedback how we would do it?
dshewmaker
2014-05-28 20:14:09
Hello, thanks for the reply.
I seem to miss when posts are replied to...
I am trying to restart the game with the master client (windows) and start all clients again. Players are actually on android tablets. I am using automatically synch scenes. When the scene restarts there are issues. I think I have resolved all, but I end up not having a master client on restart and I have to close all instances of the game and start over.
Is there a way to have the master client be the same unless it quits? it seems to not stick very well to the 1st client that is master.
dshewmaker
2014-05-28 21:28:03
So I figured out what was causing the master client to be none of the clients. I am synching scenes and I had this code running in the scene:
PhotonNetwork.networkingPeer.CrcEnabled;
Which is fine the first time you load the scene. Every time after this generated an error that you can't do this when you are already joined to a room. If I check first to see if it is true and don't set it if so the master client stays the same and everything is well. I don't know why that would affect the master client so drastically? I think this was actually the root of many of my issues trying to clean out the room and start over.
Maybe this will help someone in the future.
Hi, I suppose that you did set PhotonNetwork.networkingPeer.CrcEnabled to some value. The code above does nothing.
In any case please use PhotonNetwork.CrcCheckEnabled for setting crc mode for safety. It checks client state before setting value and prints debug message only if in wrong state instead of throwing an error.
Back to top