I am making a platformer game, i have been working on it for a while, but i have hot a roadblock. In my game there are multiple coins and items across the map, i also have a lot of different scenes, but need to be able to save what has been picked up and what hasn’t across scenes. I don’t want to be able to pick up a coin, go to a different scene (the home for instance) and then come back and be able to pick up the same coin again.
Read about “Storage” to save the progress of your game.
Ok, thanks. Were would i read “storage”?
After you read that, if you are still not sure how to save each coin: you probably want to save the state fo each coin as true or false (or better 1 and 0) depending on if it has been collected. You can save the state of all coins in a singe variable that way. It would look something like this: 110001 → the first 2 coins have been collected, so has the 6th.
When entering the level you want to do a ‘for each coin’ and check if each coin is ‘true’ or ‘false’ and hide them if they are collected. (you don’t want to destroy them as that would change the amount of coins in the level and probably fuck up your saving logic).
You can also save them one file per level. lvlX → coinX → true/false but that would take up way more space.
Ok thanks! I’ll see if it works. I have another question, how do i go to another scene, and then come back and my character will be in the same spot.
As far as I know you can just change the scene with the ‘pause and start a new scene’ and then go back with ‘stop and go back to previous scene’.
If that doesn’t work just save the player position in a global variable or storage, depending on what exactly you want to archive.