Hello! We are trying to make a multiplayer game. We have bots in game and all the bots are controlled by master client. The problem is that the method is not called immediately when the master client closes the application / shuts down the device / goes to the main screen. I mean the method is called after sometime but in some weird order:
1. master client closes the application / shuts down the device / goes to the main screen
2.. master client returns to the application
3. hasFocus = false
5. setMaster
4. hasFocus = true
But we need it to work in another order:
1. master client closes the application / shuts down the device / goes to the main screen
3. hasFocus = false
5. setMaster
2. previous master client returns to the application
4. hasFocus = true
1. master client closes the application / shuts down the device / goes to the main screen
2.. master client returns to the application
3. hasFocus = false
5. setMaster
4. hasFocus = true
But we need it to work in another order:
1. master client closes the application / shuts down the device / goes to the main screen
3. hasFocus = false
5. setMaster
2. previous master client returns to the application
4. hasFocus = true
- void OnApplicationFocus( bool hasFocus )
- {
- if (PhotonNetwork.isMasterClient && !hasFocus) {
- if (PhotonNetwork.otherPlayers.Length > 0) {
- agent.enabled = false;
- PhotonNetwork.SetMasterClient (PhotonNetwork.otherPlayers [Random.Range (0, PhotonNetwork.otherPlayers.Length)]);
- }
- }
- }