Play a Skillz Match

In this article, you'll learn how to create the Skillz Delegate and how to perform the necessary Skillz function calls. If you haven't installed the Unity SDK to your Unity project, please refer to this article on how to do so.

Step 1: Generate the Skillz Delegate

Open the initial game scene that Unity will load when starting a new match, and select Skillz -> Generate Delegate

81469875.png

This will create a "SkillzDelegate" game object for you. This “SkillzDelegate” game object will contain your game’s ID, orientation, and the Skillz Delegate Script.

4806988.png

Step 2: Modify your Skillz Delegate

Edit your "SkillzDelegate" game object. Input your game ID and choose whether it's in a sandbox or production environment. Make sure to choose sandbox if you are still in the testing phase of your integration.

10154401.png

Next, click on the SkillzDelegate script and open it in your favorite code editor. Implement your OnMatchWillBegin and OnSkillzWillExit methods by specifying what scene should load in that particular situation. OnMatchWillBegin is required to implement, while OnSkillzWillExit is optional if your game is not meant to exit out of the Skillz UI.

75202499.png

Step 3: Launch Skillz

You can launch Skillz by creating a button specifically for that purpose, or you can have Skillz launch automatically, as soon as Unity opens.

public void Play ()
{
    SkillzCrossPlatform.LaunchSkillz();
}

Step 4: Add Game Parameters to your game

If you want to add game parameters to your game, you can add them in the Developer Portal. These game parameters can change the experience of each tournament since you can pass these parameters onto your code and use them to diversify the gaming experience. You can retrieve these game parameters by calling:

SkillzCrossPlatform.GetMatchRules();

This will return a Hashtable; for more information on Game Parameters, see this article.

Step 5: Updating the Player's Current Score

You should update the player's current score each time the score increments or decrements in the UI. This helps detect potential cheating and fraudulent activities by players in the game.

if (SkillzCrossPlatform.IsMatchInProgress ())
{
    SkillzCrossPlatform.UpdatePlayersCurrentScore(uiScore); 
}

Note: You can use isMatchInProgress to check whether the player is in a Skillz game or not.

Step 6: Report the Player's Final Score

When the game ends, you will need to report the final score to the Skillz servers. This will launch the Skillz UI and present the results to the player.

if (SkillzCrossPlatform.IsMatchInProgress ())
{
    SkillzCrossPlatform.ReportFinalScore(uiScore);
}

Note: You can use isMatchInProgress to check whether the player is in a Skillz game or not. It may be useful at this point to unload some of your game objects in order to reduce memory pressure.

Step 7: Aborting Players

Certain games allow players to abort a match.  This means that no score will be submitted, and they will automatically forfeit to their opponent.  If your game allows mid-match aborts, then you should call the following:

SkillzCrossPlatform.AbortMatch();

This will notify Skillz that the player has aborted, and redisplay the Skillz UI.

Step 8: Implement Skillz Random for fairness

If your gameplay makes use of random numbers, you should use the Skillz Random Number Generator. For example, if your game creates a random map for each match, using this will present the exact same random map to both players in the match, to ensure the matches are fair. Inside the SkillzCrossPlatform.cs file, there is a Random class that you can use to implement fairness in your game.

Example: SkillzCrossPlatform.Random.Range(minPos, maxPos)

You have now finished the required integration steps. Feel free to build to an Android device or to export to an Xcode Project for iOS. If you’d like to learn more, you can read about advanced Skillz Unity API features here.