How do you save your game progress between scenes in Unity?
After finishing the integration of your saving system in Unity, the thing that you might notice is that it only works in one scene. You are curious how to make multiple levels and ensure that the saving system will save your player's position, health, score and even the level scene in which the progress is saved. Just like the previous tutorial, this tutorial also uses JSON like in the Save Game in Unity video that was posted in April 2024.
If you want to make a level system for your game in Unity, you will need to open your level loader script. This C# script contains the if-statement that checks if you have a sufficient amount of coins. You also need to add a static int that will describe your current level. The level value will be connected to the Scene Manager.
What does that mean?
In the load level script, for the integer that defines your current level, you need to make sure that it is checked in the void which contains a system of levels.
If the value is 0, it means you are on the first level. case 0 will consist of only one line: scenemanager.loadscene("SampleScene"). If the level value is 1, then it should load the second level, it will have SceneTwo inside the LoadScene() function.
This scene is just a duplicate of the SampleScene, with some small differences. You can also add multiple levels, but that will make the level system even more complex.
Now it is time for the saving system. Go to player data and add public int level. Save the script and go to Player Data Manager. Make sure that you put the level value into the playerData. For introduction, you should use LevelLoader.level in order to make it work properly.
Support the Creator of Kozmobot on the social networks!
CHECK OUT MY WEBSITE: http://kozmobot.com
GITHUB: https://github.com/kozmobotgames/Save...
INSTAGRAM: / kozmobot.channel
TIKTOK: / kozmobot.channel