Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 KBurchfiel · Jun 24, 2016 at 02:40 AM · savescoresave dataitemitem pickup

How to make sure score can't be increased by picking up same item multipe times--new idea

Hi everyone,

So I've been thinking about how to make sure that a pickup item only increases a player's score by one, even if it's picked up again after it resets. (The picked up item will come back after I leave a level and return to it.) This is a problem because a player could win by leaving a level, coming back, and picking up the items again for extra points.

I asked about this earlier and got some great feedback, but I thought of an (admittedly cumbersome) system that could solve the problem, as long as I find a way to save the player's item counts and score. I'd love to hear your input. Thanks!

What I have in mind 1. Give all your pickup objects a unique tag, even if they’re the same kind of object with the same purpose, and a unique count value in your script (e.g. item 1 count, item 2 count, and so forth). 2. When you pick up an object, set its unique count number equal to 1 (not +1), and destroy/deactivate the object. 3. Make your master item count a sum of all the unique item counts (e.g. master count = item 1 count + item 2 count + item 3 count, and so on). 4. The idea behind this is to make sure that you can’t increase your item count by re-collecting the same item, even if the item reappears after you save and restart. The item count would go from "1" to "1," not 1 to 2 (since you set the count to 1 whenever you pick it up.) 5. For this system to work, you will need to save the item counts and total counts, but it shouldn’t be hard to do this with some sort of “Don’t destroy on load” script. 6. Here’s how this will work: after you save or move to a different level and back, the items will come back, but your count will stay the same (if you’ve worked that out in your script). So say you’ve already collected items 1 and 2, meaning your total item count is 2. When you return to the scene or restart, the item count will be 2, and the items will be back. However, if you pick up the items again, your score won’t go up; the values were already set to 1, and picking them up will just set the count to 1 again.

I plan to have 150-180 pickups, so this would be kind of time-consuming, but not too bad.

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
0

Answer by allenallenallen · Jun 24, 2016 at 04:11 AM

I would simply just add all the pickups into one list. Then have another list with the same number of entries of booleans for the player. Each time the player gets a new pickup, the boolean for that pickup is changed to false. And now whenever the player loads a new level, the level will only spawn the pickups depending if the corresponding boolean list is true. So if the player has picked up everything in this level, when this level is loaded again, no pickups will even spawn to begin with.

And if you want the items to spawn each time the level is reloaded. Simply just stop adding to the score by checking the boolean list to see whether or not the player has already obtained the item.

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
avatar image
0

Answer by KBurchfiel · Jun 24, 2016 at 06:10 AM

That's really interesting--I haven't thought about that approach before. Could that method also work with saving the game and reloading it? Do I need to put the boolean script under a "Don't destroy on load" command, or will that not be necessary?

I will fiddle around with my scripts and look into this. Thank you for the insight!

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

45 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Android, How can I permanently save data? (A couple variables) 4 Answers

Is there a way to save a 2D characters path and replay it on respawn? 0 Answers

Best Way to do Regular Items and Weapons/Intractable/Special Items. 1 Answer

How can i get the following script back on track to being a single level high score saver 0 Answers

Save&load 100% works on pc, but not on android! 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