Jump to content
  • Advertisement

Recommended Posts

I want to save the highest time and spend it, but somehow only the time before that is saved and spent. Maybe someone can help me?

2.PNG

Share this post


Link to post
Share on other sites
Advertisement

Unless you have a very specific reason not to, you should put your PlayerPrefs.Save calls AFTER the SetFloat calls.

Share this post


Link to post
Share on other sites

First off, use code tags.

Second, variable names. 'm' and 'n' may make sense now, but they definitely won't from few months from now. Keep your variable names meaningful.

Third, remove duplicate code. Put "PlayerPrefs.Save()" outside the brackets (just before "highscorelayer.SetActive(false)". Remove other "PlayerPrefs.Save()" calls. This will also solve your original problem.

Finally, is there a reason for storing minute and seconds separately? Why not store time in seconds or milliseconds and resolve the number of minutes from that? This will basically half the highscore logic you've written.

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!