Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 lemiwinks · Nov 13, 2013 at 08:14 PM · scorecall

different score amounts for each level

hi all, im creating a golf type game which uses a par system, giving stars out at the end of a level depending how many shots the players takes to complete it. like angry birds, the least number of shots gives 3 stars.

my problem lies with the score system, each level will have a different set of par scores, for examaple level 1 will give 3 stars at 2 shots or less, where level 2 gives 3 stars on 4 shots or less.

so far i figured id create a bunch of floats in another "master score script" eg: level1_parcount_1star = 1 level1_parcount_1star = 3 level1_parcount_1star = 6 and so on for each level.
my 1st problem is how would i call in another script back to these to check these values. i dont want to make a differnet scri[pt for each level, i need a way to;

call the master score script, find current level find par count for current level

so far im messing around with this kind of line, this would use the current levels name ParBerry3 = uiScoreBack.GetComponent().((application.loadedlevelname)Par3Count)

any help would be great =]

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Kurius · Nov 13, 2013 at 08:21 PM

You should store all of that data in Unity PlayerPrefs. see here

Comment
Add comment · Show 3 · 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 lemiwinks · Nov 13, 2013 at 09:12 PM 0
Share

i thought about using playerprefs, but would i make a call at the start of the game giving all the levels there score counters?

avatar image Kurius · Nov 13, 2013 at 09:28 PM 1
Share

At the beginning of the game, perform a read of the PlayerPrefs. If PlayerPrefs is read to be empty, then at this time set the default values, else read the current values and display them. At the end of each level that the user plays, update the PlayerPrefs with the latest values. Next time the user plays the game, the PlayerPrefs will have remembered what the latest values were.

avatar image lemiwinks · Nov 13, 2013 at 09:30 PM 0
Share

ok great, ill give that a shot. thanks dude =]

avatar image
0

Answer by Entwicklerpages · Nov 13, 2013 at 09:32 PM

I think it would be a good idea to make a simple MonoBehaivor that has only some public vars. (for example integers) You put the Script Component with this Behaivor on something like a "LevelController" object. Then you set the least number for this level.

You can get these integers simply with something like this (C#)

 YourDataClass data = levelController.GetComponent<YourDataClass>();

 Debug.Log(data.leastShots);


Please don't make a gigantic class with tons of vars in it! Each time you add a level you must edit this class and put a bunch of new vars in it. Simple make one MonoBehavior class and put that Component in the levels. Then you can simply edit your settings in the editor.

Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

17 People are following this question.

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

Related Questions

Multiple Cars not working 1 Answer

getting a float value from another script 1 Answer

Score System help 1 Answer

You are not allowed to call this function when declaring a variable 1 Answer

Help! Why doesn't this work? GUI/Static vars Help! Javascript 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