I have a game that I would like to be able to save, but I don’t know how to do it.
I want the player to be able to do an overall save of the entire game, but also make it so that when a player travels from level to level it saves the levels he is not in. For instance, I have my main world, and when the player walks into a trigger collider, it loads a cave level, how do I save the state of the world so that the player is right back outside of the cave when the world level is reloaded on exit of the cave?
You can store certain string, integers, or floating point variables using Player preferences.: Here
What you can do is that you have a variable called “currentLevel”, so when the player plays the game for the first time, its value would be 1. When the player reaches the trigger that takes him to the next level, you increase it from 1 to 2.
One more thing that you have to do is that everytime the player starts the game, you check the value of currentLevel, if its 3, that means that the player had reached till the third level, so you load the third level.
You can also use a similar idea to store a user name or the score of the player.