Stats are a convenient way of tracking player information such as game wins, losses, kills, deaths, etc. Many platforms have a feature to display a player’s stats.

PLAYERSTATS

Stats are automatically saved to a file, named PLAYERSTATS, then asyncrously set on your platform’s backend. We do this to ensure a single development workflow where savings stats to PLAYERSTATS file is a reliable method of tracking stats for any platform. This also allows the developer to setup stats on platform backends in hindsight.

Code Sample - Set Stat

Set a stat value

...
public static void SetStat(PlatformPlayer player, Stat stat, float value)
{
	player.SetStat(stat, value, 
		(value, result) =>
		{
			if(result == PlatformPlayer.StatResult.Success)
			{
				Debug.Log("Stat successfully set!");
			}
		}, 
		(value, result) =>
		{
			if(result == PlatformPlayer.StatResult.Success)
			{
				Debug.Log("Platform stat set successfully!");
			}
		}
	);
}
...

Flowchart - Set Stat

SetStat.drawio.png

Create a Stat Object

ex: Stat scriptable object for ‘Games Won’

Untitled

Link Stats to Achievements

  1. Select an Achievement object
  2. Add a Stat Requirement
  3. Assign the Stat object and set the Required Value