Key points for multiplayer games only

Back Button Functionality (Only For Multiplayer Games)

When the user presses Back button to quit the game, we provide a callback to the client.

Use this callback function to write additional logic, like gameover or sending some event etc. You need to listen to the event “StartListeningBackButtonPressed” present in the WinzoEventManager.dll

Add these lines in your script.

void Start()
 {
     WinzoEventManager.StartListeningBackButtonPressed(OnBackBtnCallback);
 }
 public void OnBackBtnCallback()
 {
    // write your logic here
 }

Start Sending Score (Only For Multiplayer Games)

“TriggerScoreListentingEvent” is to be triggered when the loading/connection screen is over and the player is actually in the gameplay/game screen.

WinZO starts sending scores to the server when the game gets loaded. If the game is loaded but does not start because of internet/connectivity issues, then we don't want to send 0 score to the server every second.

public void StartListeningToWinzoScore()
       {
           WinzoEventManager.TriggerScoreListeningEvent();
       }

Checklist for Multiplayer game/Photon game

*NOTE: Please assign PhotonView, PhotonTransformView and all other photon related scripts through script only.

  1. If your game uses Photon, please use Photon PUN-2 provided by WinZO in the SDK.

  2. Matchmaking will be done on WinZO’s end and WinZO will provide players, room id, game time, turn time etc. in the setup game event to your game. You need to start a match based on the data shared by WinZO.

  3. Please don’t show any UI (enter name, enter room id, public room, private room, start button, game lobby, rooms present). After the game is loaded show only one UI (waiting for player) and when all players are connected then start the match.

  4. For instantiating objects, please do not use the string which we commonly pass in PhotonNetwork.Instantiate (“player”).

  5. Please have a reference to the prefab in your script and use prefab.name to instantiate the GameObject, because all the assets are present in AssetBundle.

  6. In Photon games, to instantiate a GameObject we generally keep that prefab in Resources Folder. Do not keep that in the Resources folder, just add PreparePool.cs script (Present in SDK and add your namespace as well) on a gameobject. Keep reference of those prefabs in this script and assign them from the inspector.

  7. Developer to ensure that reconnection is working properly i.e., player should be able to reconnect to the match and continue their game from the point where they got disconnected without any problem within a given time (30 seconds). Internet fluctuation should not lead to game termination.

  8. The players, objects, enemies, and scores should always be in sync before and after reconnection.

  9. If one player leaves the game by going to the background or quits by pressing the back button, we will stop their game and they won't be able to reconnect back, in that case the other player will wait for a specific time (=reconnection time) and will be announced the winner.

  10. Please disconnect from photon at game over function or on OnDisable() function.

  11. There might be a possibility that the PhotonView component on the objects might go missing while importing the asset bundle into the WinZO project, which is why it is necessary to add the PhotonView from your script.

  12. Multiplayer games in Background-Foreground: Multiplayer games should run and sync after returning from the background similar to how reconnection works after internet disconnection. The game should sync after coming back from the background if the game is still running, else the game will call submitScore with score of 0 along with other submit score data. Therefore, all the objects having the PhotonView component and their properties must be assigned via script. An example screenshot is shown below.oe

 private void Awake()
       {
           if (gameObject.GetComponent<Photon.Pun.PhotonView>() == null)
           {
               gameObject.AddComponent<Photon.Pun.PhotonView>();
               gameObject.GetComponent<Photon.Pun.PhotonView>().ViewID = 26;
           }
       }

Asset Bundle must be created via WinZO’s SDK. If any of your objects contains the PhotonView or PhotonTransformView component, the Sample project would make sure that it is removed from the objects before creating the bundle.

Last updated