Achievements

Achievements are a great way to track what a player has done in your game and to give the player more incentive to keep playing your game. An achievement represents a quantitative goal that the player can accomplish in your game. As the local player plays your game, they make progress towards completing the achievement. When the player meets or exceeds the goal, the achievement is considered earned, and the player is rewarded. Your game defines the goal and the game mechanics that describe how a player earns the achievement.

Unlocking achievements

To unlock an achievement, call the Unlock method and pass in the achievement ID. The following code snippet shows how your app can unlock achievements:

using SA.CrossPlatform.GameServices;
...

string achievementId = "YOUR_AchievementId_HERE";
var client = UM_GameService.AchievementsClient;
client.Unlock(achievementId, (result) => {
    if(result.IsSucceeded) {
        Debug.Log("Unlocked");
    } else {
        Debug.Log("Failed: " + result.Error.FullMessage);
    }
});

If the achievement is of the incremental type (that is, several steps are required to unlock it), call Increment() instead. The following code snippet shows how your app can increment the player’s achievement:

using SA.CrossPlatform.GameServices;
...

int numSteps = 5;
var client = UM_GameService.AchievementsClient;
client.Increment(achievementId, numSteps, (result) => {
    if (result.IsSucceeded) {
        Debug.Log("Incremented");
    } else {
        Debug.Log("Failed: " + result.Error.FullMessage);
    }
});

Note: All iOS achievements are considered to have 100 steps. 

Displaying achievements

To show a player's achievements call the ShowUI method. The following code snippet shows how your app can display the default achievement user interface.

UM_GameService.AchievementsClient.ShowUI();

Creating In-Game achievements UI

If instead of using the default Google Play UI, you would like to build your own achievements in-game UI, you can load the achievements metadata. See the snippet below:

using SA.CrossPlatform.GameServices;
...

var client = UM_GameService.AchievementsClient;
client.Load((result) => {
	if(result.IsSucceeded) {
	    foreach(UM_iAchievement achievement in result.Achievements) {
	        AN_Logger.Log("achievement.Identifier: " + achievement.Identifier);
	        AN_Logger.Log("achievement.CurrentSteps: " + achievement.CurrentSteps);
	        AN_Logger.Log("achievement.TotalSteps: " + achievement.TotalSteps);
	        AN_Logger.Log("achievement.Type: " + achievement.Type);
	        AN_Logger.Log("achievement.State: " + achievement.State);
	    }
	} else {
	    Debug.Log("Failed:  " + result.Error.FullMessage);
	}
});

Note:  There is no way on iOS to get a server-side achievements list. On iOS Load method will only return information about achievements you already submitted progress for. The only workaround is to list all achievements you have with the Editor UI. And when Load method is called, the achievements list will merge with server-side unlocked achievements info. If you haven't added any achievements inside editor UI, Load function will only load achievements that already have some progress.

The UI for listing iOS achievements can be found inside the iOS Native plugin UI. With the Ultimate mobile you mat located it by the following path:

  1. Sietch to IOS editor
  2. Click on the Game Kit Framework

   3. List your application iTunes achievements