- Home /
Question by
SavvaMadar · Feb 27, 2014 at 10:55 PM ·
networkingmultiplayerphoton
Close room on host exit
I want to close the room on host exit, i have this code:
for( var pp : PhotonPlayer in PhotonNetwork.playerlist){
if(pp.isMasterClient==false){
//kill clients first
pp.gameObject.getComponent(Script).exit();
}
}
//kill master
exit();
how do I make it work, gameObject not a member of PhotonPlayer
Comment
With Photon, you can use the function call On$$anonymous$$asterClientSwitched(). If the Host leaves, this function is called. From there you can disable/move/reset objects and then leave the room :
function On$$anonymous$$asterClientSwitched()
{
DebugLog( "On$$anonymous$$asterClientSwitched()" ); // $$anonymous$$asterServer has dropped out
// return to the $$anonymous$$ain $$anonymous$$enu
DisconnectFromRoom();
}
function DisconnectFromRoom()
{
DebugLog( "DisconnectFromRoom()" );
// do stuff
// go back to main menu (select single/multi player again)
PhotonNetwork.LeaveRoom();
PhotonNetwork.Disconnect();
PhotonNetwork.offline$$anonymous$$ode = false;
}