Creating a "Super Mario 64" "Power Star" to unlock scenes?

How would someone go about making an object like the power stars you have to collect to unlock doors that need different amounts of stars? I think this opens up to less linear gameplay so I’m trying to figure it out for my 3D platformer.

I’m guessing it would be a coin, and a door that will open/unlock if you have enough coins but not take away the coins you have so you can keep collecting for later doors? Also the coin amount would need to save as you travel through scenes.

Any code ideas?

Also here is my platformer is anyone was wondering :wink:

Well you can start by having a int variable somewhere and add +1 to that variable every time you collect a coin or star or whatever the object you want to use, then when you get close to a door you check that variable against the number needed to open the door, if is equal or greater than this number then the door opens.

Its fairly easy to do.

In the case of Super Mario 64, the save files shouldn’t be that large, as you only need to store which Stars are gone, which Keys you have, and which hats you have unlocked. With 120 stars, 2 keys, and 3 hats, that could be done in 125 zeros and ones. Another flag for when Bowser is finally defeated, which I think needs to happen before the cannon to the roof opens. Maybe a couple other settings that I am forgetting (pink bombomb cannons? or do those unlock automatically at other star levels.?)

To get things to transition between scenes, use DontDestroyOnLoad on the script that is storing the star values. Then you don’t have to save everything each time you move between levels (Though depending on your game design, you may want to).

In storing things between play sessions, you will need to save the data off somewhere. Simple things might get by with PlayerPrefs. There are more save solutions if you need more data, such as writing things to an xml file.

Would defitely not recommend PlayerPrefs for that, as then your going to allow players to easily edit there amount.

That’s a much better method

Yes, I agree that saving things off in that manner will be stronger and more than PlayerPrefs.