Achievements can be used to reward the player following some specific actions in your game. He can be rewarded with currencies, virtual items, progression or leaderboard score.
AchievementData
id (string): Unique id for this achievement.
requestName (string): Name use to call the achievement by a user friendly name.
name (string): Name of the achievement.
description (string): Description of the achievement.
rewards (List<Reward>): List of rewards when this achievement is finish and claimed. See Achievement Reward Data for more informations.
setBy (string): Let you know who can trigger this achievement (server or client).
isClaimable (bool): Let you know if the achievement is ready to be claimed.
valueToReach (int): Value to reach in order to claim this achievement.
completedAchievementsToUnlock (List<string>): List of other achievements required to unlock this one.
repeatable (bool): Let you know if this achievement can the triggered and claimed multiple time.
repeatNoMoreOftenThanCron (string): Let you set a period where this achievement can be repeated (daily, weekly, monthly). Can be set using cron setting.
startTime (long): The start time of this achievement. Cannot be triggered before this date.
endTime (long): The end time of this achievement. Cannot be triggered after this date.
resetTimeLimitEvery (string): Reset the start and end time based on a cron setting.
Achievement Reward Data structure
type
The reward type : currency, progression, item_by_id, setLeaderboardScore, addLeaderboardScore.
name
The name of the reward.
quantity
The quantity of the reward that will be given to the user upon completing the achievement.
For "item_by_id" and "currency", it represents the number of items or coins rewarded.
For "progression", it represents the increment value for the user's progression.
For "setLeaderboardScore", it represents the score that will be set for the current user to the leaderboard
For "addLeaderboardScore", it represents the score that will be added for the current user to the leaderboard
appIds
List of project id where the rewards will be given.
Get game achievements
usingUnityEngine;usingRGN.Modules.Achievement;usingSystem.Collections.Generic;publicclassAchievementExamples:MonoBehaviour{privateasyncvoidGetAllGameAchievements() { // Retrieves the 10 first achievements setup for my gameList<AchievementData> achievements =awaitAchievementsModule.I.GetForCurrentAppAsync(10);foreach (var achievement in achievements) {Debug.Log($"Achievement name : {achievement.name} \n"+$"Description : {achievement.description}"); } }}
Get user achievements
This function returns the completed and on going achievements for the user.
usingUnityEngine;usingRGN.Modules.Achievement;usingSystem.Collections.Generic;publicclassAchievementExamples:MonoBehaviour{privateasyncvoidGetUserAchievementsAsync() {List<AchievementWithUserData> achievements =awaitAchievementsModule.I.GetForCurrentAppWithUserDataAsync(10);foreach (var achievement in achievements) {UserAchievement userAchievement =achievement.GetUserAchievement();Debug.Log($"Achievement name : {achievement.name} \n"+$"Achievement progression : {userAchievement.value}/{achievement.valueToReach}"); } }}
Trigger achievement by id
usingUnityEngine;usingRGN.Modules.Achievement;publicclassAchievementExamples:MonoBehaviour{privateasyncvoidCompleteAchievementAsync() {awaitAchievementsModule.I.TriggerByIdAsync("myAchievementId"); // This will increase the achievement progression by 1 // An additionnal parameter can be passed to increase the progress amount }}
Trigger achievement by request name
The request name can be set in the developer dashboard when creating the achievement.
usingUnityEngine;usingRGN.Modules.Achievement;publicclassAchievementExamples:MonoBehaviour{privateasyncvoidCompleteAchievementAsync() {awaitAchievementsModule.I.TriggerByRequestNameAsync("myRequestName"); // This will increase the achievement progression by 1 // An additionnal parameter can be passed to increase the progress amount }}
Claim achievement by id
If the achievement is not set to be automatically claimed when completed, you can claim it in game to show to the player the rewards he received.
usingUnityEngine;usingRGN.Modules.Achievement;usingSystem.Collections.Generic;publicclassAchievementExamples:MonoBehaviour{privateasyncvoidClaimAchievementAsync() {var result =awaitAchievementsModule.I.ClaimByIdAsync("achievementId");List<AchievementReward> rewards =result.rewards;foreach (var reward in rewards) {Debug.Log($"Reward name : {reward.name} \n"+$"Reward type : {reward.type} \n"+$"Reward quantity : {reward.quantity}"); } }}
Claim achievement by request name
If the achievement is not set to be automatically claimed when completed, you can claim it in game to show to the player the rewards he received.
The request name can be set in the developer dashboard when creating the achievement.
usingUnityEngine;usingRGN.Modules.Achievement;usingSystem.Collections.Generic;publicclassAchievementExamples:MonoBehaviour{privateasyncvoidClaimAchievementAsync() {var result =awaitAchievementsModule.I.ClaimByRequestNameAsync("myRequestName");List<AchievementReward> rewards =result.rewards;foreach (var reward in rewards) {Debug.Log($"Reward name : {reward.name} \n"+$"Reward type : {reward.type} \n"+$"Reward quantity : {reward.quantity}"); } }}
Unreal
Unreal integration
Coming soon
Achievements
Integration Guide
The AchievementsModule allows to give the user different rewards for making progress. The first things you'll need to decide are when you want to reward the user and what should be given as a reward.
Currently, the achievements support 3 types of user rewards:
Virtual Items rewards - the virtual items are added to the user's inventory
Currency Coins rewards - the currency coins are added to the user's data. It is not possible to give the "rgn-coin" as a currency reward here.
Progression rewards - If you want to track user progress. You can use custom progression data types and store those in the user's data. When the achievement is completed and the progression rewards are given, it will increment the user's progression values accordingly. The progression values should be numbers. To retrieve the progression data you need to use the GameProgressModule:GetUserProgressionDataAsync() method.
You can create new achievements by using the developer dashboard or by reaching out to the PLAY team.