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.

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.

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!