Problem is not reproducible or outdated
google achievements and leaderboard problem
I have a problem with google achievements and leader board .I have them working but in the leader board the score changes when you exit the game and play again, also the achievements do the same.Here is the code.
public class achActive : MonoBehaviour {
private int score;
private int gamesplayed;
void Awake()
{
gamesplayed = PlayerPrefs.GetInt("gamesplayed");
score = PlayerPrefs.GetInt("BestScore");
}
void Start()
{
// achievement
if (score >= 50)
{
Social.ReportProgress("Id", 100.0f, (bool success) =>
{
});
}
// achievement
if (score >= 100)
{
Social.ReportProgress("Id", 100.0f, (bool success) =>
{
});
}
// achievement
if (score >= 300)
{
Social.ReportProgress("Id", 100.0f, (bool success) =>
{
});
}
// achievement
if (score >= 500)
{
Social.ReportProgress("Id", 100.0f, (bool success) =>
{
});
}
// achievement
if (gamesplayed >= 1000)
{
Social.ReportProgress("Id", 100.0f, (bool success) =>
{
});
}
// leaderboard
Social.ReportScore(score, "Id", (bool success) => {
// handle success or failure
});
}
}
Answer by KdRWaylander · Dec 02, 2015 at 03:12 PM
Hi,
That's because you call your different if statements that update the achievements only in the start function :)
You should create a function called like UpdateAchievements (), in which you put all the code you wrote in Start () function. Then you call this function within Start () or whenever your want ... like at the end of a game.
void Start () {
UpdateAchievements (); //That's how to call the function by script
}
public static void UpdateAchievements () { //Public+static so you can call it from anywhere
// Code you wrote ...
}
the problem i happening again the score changes when the game is restarted
Follow this Question
Related Questions
Unity Codeless IAP, Google Play Services Sign-in, Leaderboards and Achievements NOT WORKING! 0 Answers
2021.2.7: DownloadHandlerTexture and UnityWebRequestTexture not recognized? 1 Answer
Someone please help me with combination lock 0 Answers
I have a few questions 1 Answer
Google Play Services Login isn't working 0 Answers