Skip to content

Use Asset Instance Progressions

This how-to retrieves an Asset instance's Progressions in your game, and adds, subtracts, resets, or deletes its points on a Progression.

Prerequisites

An Asset instance is started on a Progression the moment you add points to it — you don't need to create the association separately. It's then listed when retrieving Progressions for that Asset instance.

Retrieve Asset Instance Progressions

Get a Single Asset Instance Progression

int assetInstanceId = 1;
string progressionKey = "mage";
LootLockerSDKManager.GetAssetInstanceProgression(assetInstanceId, progressionKey, response =>
{
if (!response.success) {
Debug.Log("Failed: " + response.Error);
}
// Output the asset instance level and show how much points are needed to progress to the next tier
Debug.Log($"The asset instance is currently level {response.step}");
if (response.next_threshold != null)
{
Debug.Log($"Points needed to reach next level: {response.next_threshold - response.points}");
}
});

See the Reference Documentation for the full response.

Get All Asset Instance Progressions

int assetInstanceId = 1;
LootLockerSDKManager.GetAssetInstanceProgressions(assetInstanceId, response =>
{
if (!response.success) {
Debug.Log("Failed: " + response.Error);
}
// Output the asset instance level and show how much points are needed to progress to the next tier for all asset instance progressions
foreach (var assetInstanceProgression in response.items)
{
Debug.Log($"Current level in {assetInstanceProgression.progression_name} is {assetInstanceProgression.step}");
if (assetInstanceProgression.next_threshold != null)
{
Debug.Log($"Points needed to reach next level in {assetInstanceProgression.progression_name}: {assetInstanceProgression.next_threshold - assetInstanceProgression.points}");
}
}
});

See the Reference Documentation for the full response.

Get All Asset Instance Progressions Using Count

Count limits the number of entries returned.

int assetInstanceId = 1;
int count = 20;
LootLockerSDKManager.GetAssetInstanceProgressions(assetInstanceId, count, response =>
{
if (!response.success) {
Debug.Log("Failed: " + response.Error);
}
// Output the asset instance level and show how much points are needed to progress to the next tier for all asset instance progressions
foreach (var assetInstanceProgression in response.items)
{
Debug.Log($"Current level in {assetInstanceProgression.progression_name} is {assetInstanceProgression.step}");
if (assetInstanceProgression.next_threshold != null)
{
Debug.Log($"Points needed to reach next level in {assetInstanceProgression.progression_name}: {assetInstanceProgression.next_threshold - assetInstanceProgression.points}");
}
}
});

See the Reference Documentation for the full response.

Paginate Asset Instance Progressions

Use the After parameter to paginate if the Asset instance is on many Progressions.

int assetInstanceId = 1;
int numberOfItemsPerPage = 10;
LootLockerPaginatedAssetInstanceProgressionsResponse assetInstanceProgressions;
void Start()
{
LootLockerSDKManager.StartGuestSession(_ =>
{
// Fetch the initial asset instance progressions list
LootLockerSDKManager.GetAssetInstanceProgressions(assetInstanceId, numberOfItemsPerPage, response =>
{
if (!response.success)
{
Debug.Log("Failed: " + response.Error);
}
if (response.pagination.total == 0)
{
Debug.Log("Your asset instance does not have any progressions, start them by giving it some exp");
}
assetInstanceProgressions = response;
});
});
}
void Update()
{
if (assetInstanceProgressions == null) return;
// Fetch the next page if more asset instance progressions exist
if (Input.GetKeyDown(KeyCode.RightArrow) && assetInstanceProgressions.pagination.next_cursor != null)
{
LootLockerSDKManager.GetAssetInstanceProgressions(assetInstanceId, numberOfItemsPerPage, assetInstanceProgressions.pagination.next_cursor, response =>
{
if (!response.success)
{
Debug.Log("Failed: " + response.Error);
}
assetInstanceProgressions = response;
Debug.Log($"Paginating right, got {assetInstanceProgressions.items.Count} progressions");
});
}
// Fetch the previous page if we are not on the first page
if (Input.GetKeyDown(KeyCode.LeftArrow) && assetInstanceProgressions.pagination.previous_cursor != null)
{
LootLockerSDKManager.GetAssetInstanceProgressions(assetInstanceId, numberOfItemsPerPage, assetInstanceProgressions.pagination.previous_cursor, response =>
{
if (!response.success)
{
Debug.Log("Failed: " + response.Error);
}
assetInstanceProgressions = response;
Debug.Log($"Paginating left, got {assetInstanceProgressions.items.Count} progressions");
});
}
}

See the Reference Documentation for the full response.

Update Asset Instance Progressions

Add Points to an Asset Instance Progression

If the Asset instance levels up, the awarded_tiers field contains the Rewards acquired.

int assetInstanceId = 1;
string progressionKey = "mage";
ulong amountOfPoints = 100;
LootLockerSDKManager.AddPointsToAssetInstanceProgression(assetInstanceId, progressionKey, amountOfPoints, response =>
{
if (!response.success) {
Debug.Log("Failed: " + response.Error);
}
// If the awarded_tiers array contains any items that means the asset instance leveled up
// There can also be multiple level-ups at once
if (response.awarded_tiers.Any())
{
foreach (var awardedTier in response.awarded_tiers)
{
Debug.Log($"Reached level {awardedTier.step}!");
foreach (var assetReward in awardedTier.rewards.asset_rewards)
{
Debug.Log($"Rewarded with an asset, id: {assetReward.asset_id}!");
}
foreach (var progressionPointsReward in awardedTier.rewards.progression_points_rewards)
{
Debug.Log($"Rewarded with {progressionPointsReward.amount} bonus points in {progressionPointsReward.progression_name} progression!");
}
foreach (var progressionResetReward in awardedTier.rewards.progression_reset_rewards)
{
Debug.Log($"Progression {progressionResetReward.progression_name} has been reset as a reward!");
}
}
}
});

See the Reference Documentation for the full response.

Subtract Points from an Asset Instance Progression

int assetInstanceId = 1;
string progressionKey = "mage";
ulong amountOfPoints = 10;
LootLockerSDKManager.SubtractPointsFromAssetInstanceProgression(assetInstanceId, progressionKey, amountOfPoints, response =>
{
if (!response.success) {
Debug.Log("Failed: " + response.Error);
}
// Output the amount of points the asset instance has after subtracting points
Debug.Log($"Asset instance now has {response.points} points in {response.progression_name} progression");
});

See the Reference Documentation for the full response.

Reset an Asset Instance Progression

Resets the Asset instance's points on the Progression to 0, returning it to level 1. To remove the Progression from the Asset instance entirely, see Delete an Asset Instance Progression below.

int assetInstanceId = 1;
string progressionKey = "mage";
LootLockerSDKManager.ResetAssetInstanceProgression(assetInstanceId, progressionKey, response =>
{
if (!response.success) {
Debug.Log("Failed: " + response.Error);
}
// Asset instance level is now 1
Debug.Log($"Asset instance is level {response.step} since the {response.progression_name} was reset");
});

See the Reference Documentation for the full response.

Delete an Asset Instance Progression

Completely removes an Asset instance Progression — it's no longer listed when retrieving the Asset instance's Progressions.

int assetInstanceId = 1;
string progressionKey = "mage";
LootLockerSDKManager.DeleteAssetInstanceProgression(assetInstanceId, progressionKey, response =>
{
if (!response.success) {
Debug.Log("Failed: " + response.Error);
}
// Trying to fetch the deleted asset instance progression will result in a "Not Found" error
LootLockerSDKManager.GetAssetInstanceProgression(progressionKey, response =>
{
if (!response.success) {
Debug.Log("Failed: " + response.Error);
}
});
});

See the Reference Documentation for the full response.

Conclusion

You've retrieved an Asset instance's Progressions and updated its points from your game. Next, explore Player Progressions or Character Class Progressions if your game also tracks progress on those holders.