• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by bubblegumsoldier · Feb 19, 2012 at 01:16 AM · score

Highscoresystem

this highscore sets highscores but when you set another highscore the third one for example doesn't get the second one:

function AddScore(){

if(PlayerPrefs.GetFloat("1_50_float") >= privatecounter){

     PlayerPrefs.SetString("1_50_string", timeCounter);

     PlayerPrefs.SetFloat("1_50_float", privatecounter);

     

     }if(PlayerPrefs.GetFloat("2_50_float") >= privatecounter && PlayerPrefs.GetFloat("1_50")<= privatecounter){



     PlayerPrefs.SetFloat("2_50_float", privatecounter);

     PlayerPrefs.SetString("2_50_string", timeCounter);

     }if(PlayerPrefs.GetFloat("3_50_float") >= privatecounter && PlayerPrefs.GetFloat("2_50")<= privatecounter){

     PlayerPrefs.SetFloat("3_50_float", privatecounter);

     PlayerPrefs.SetString("3_50_string", timeCounter);

     }

}

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Berenger · Feb 19, 2012 at 01:54 AM 0
Share

Hum, what ?

avatar image bubblegumsoldier · Feb 21, 2012 at 07:09 PM 0
Share

what I want is the 1. place to get the 2. place when I score the first place:

  1. 5:0:0

  2. 7:0:0

  3. 9:0:0

then I have got a new score with 3:0:0

in my code it looks like this:

  1. 3:0:0

  2. 7:0:0 <- still 7:0:0 but it should be 5:0:0

  3. 9:0:0 <- the same

it should look like this:

  1. 3:0:0

  2. 5:0:0

  3. 7:0:0

if you still dont understand then... forget about it

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by syclamoth · Feb 19, 2012 at 01:53 AM

How about this- inside your if-statement, after setting the score, set 'privatecounter' and 'timeCounter' to the previously saved values before passing them down to the next step:

 if(PlayerPrefs.GetFloat("1_50_float") >= privatecounter){
     var oldTime : string = PlayerPrefs.GetString("1_50_string");
     var oldPrivate : float = PlayerPrefs.GetString("1_50_float");
     PlayerPrefs.SetString("1_50_string", timeCounter);
     PlayerPrefs.SetFloat("1_50_float", privatecounter);
     timeCounter = oldTime;
     privatecounter = oldPrivate;
 }

This way, every time a score beats the current position, it displaces it instead of deleting it entirely.

Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image bubblegumsoldier · Feb 21, 2012 at 07:06 PM 0
Share

hmm I understand what you mean but how do I embedd this because this replaces it again but the last 1. place wont get the 2. place if you now what I mean.

avatar image syclamoth · Feb 23, 2012 at 03:45 AM 0
Share

Well, you still have to do all the steps. You see how you are checking the first one, then the second one, then the third one? The only difference here, is that when it beats one of them, ins$$anonymous$$d of just finishing, it changes the current value, saves the old value, and then passes that old value down to the others.

avatar image bubblegumsoldier · Feb 24, 2012 at 07:07 PM 0
Share

now I understand... but... it would be much easier if youd just do the whole script. But thanks very much!

avatar image syclamoth · Feb 26, 2012 at 03:51 AM 0
Share

I'm really not that happy with doing other people's work for them. I'm happy to help, but I want you to learn things along the way.

avatar image bubblegumsoldier · Feb 26, 2012 at 11:49 AM 0
Share

yes I understand you but I don't understand your code but that's why I just asked for help I already worked on this for hours and I don't see any possibility any more. Please help me...

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I Instantiate a prefab to touch and still update a score? 1 Answer

Networked Scoreboard / Highscore Table 2 Answers

destroy pickups after you collect them 2 Answers

Creating a spreadsheet 2 Answers

Score going up like crazy 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges