Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(2 edits) (+1)

I have this game I am making and I want an input name field panel to pop up on the GameOver screen only when the player achieves a higher score than the previous uploaded score. Of course if there is no personal entry uploaded previously I just want the score to be uploaded. I tried doing it this way to enable the input username panel:

public class UIGameOver : MonoBehaviour
{
    [SerializeField] TextMeshProUGUI scoreText;
    [SerializeField] GameObject inputPlayerPanel;
    ScoreKeeper scoreKeeper;
    private void Awake()
    {
        scoreKeeper = FindObjectOfType<ScoreKeeper>();
    }
    private void Start()
    {
        scoreText.text = "You Scored:\n" + scoreKeeper.GetScore();
        Leaderboards.Laser_Defender.GetPersonalEntry(HighScoreEntry);
    }
    void HighScoreEntry(Entry entry)
    {
        int score = scoreKeeper.GetScore();
        if (score > entry.Score)
        {
            inputPlayerPanel.SetActive(true);
        }
    }
}

And here is the submit score code:

public void SubmitScore()
{
    SetLeaderboardEntry(inputPlayerName.text, scoreKeeper.GetScore() );
    Debug.Log("Player name: " + inputPlayerName.text);
    Debug.Log("Score: " + scoreKeeper.GetScore());
}

After clearing PlayerPrefs, I tried this code got a Bad Web Request:Should I have used local variables in my code before the Personal Entry was defined or something else? 

Should I have used the Leaderboard Search query instead?

Hello David!

Are you clearing your PlayerPrefs in code before uploading an entry?

(1 edit)

No, I just cleared Player Prefs manually. The error then seemed not to appear again after playing the game a few times. Maybe it just was my internet connection? Or Maybe not.

Well then that must have been the case. The leaderboard creator probably did not get properly initialized, 'cause as far as I see from your screenshot, the userGuid parameter was empty.