I’m trying to make a game that has many different levels.
Each level it’s a different scene, and I want to save the progression of the player, so when he exist the game and comes back again he’s gonna continue/load from the level/scene that he quits.
My questions is there any specific C# command to do this(loading a level automatically without the player needs to click on any button)?
Or at least what’s the idea/theory about implementing that?
Well, you just need to save out what scene they were on. By name should be fine. Then when they start the game, check if they have a saved scene name and load it up instead of the main menu.
Ok, but the game it loads automatically a scene, the first scene how can I changed that, except from changing the scene order inside the build settings manually?
Pause it and see if there is a script somewhere that is calling the load again and again. Is your condition that ends the previous scene being cleared properly?
When the game starts the first thing is to load the file that contains the number of the scene that the player quit, and then it loads that specific number/scene. And at this point is where the loop is happening
This should help, Debug.Log is your friend. As as my hints hopefully suggested, please post your code here, using Code tags (see the Code: icon in your edit bar) Tips for new Unity users
Basicly my ideas was to save an integer variable that starts from 0 which is the build index of the first scene and every time the player wins that number will increased by 1 and every time that I load a scene, I will load that variable and also I’m saving that variable so the player will continue from the level that he quit.
What is the output of your debug statement? Does it repeat also? Also, it looks like you have an infinite loop here, LoadPlayer is calling itself over and over.
public void LoadPlayer()
{
PlayerData data = SaveSystem.LoadPlayer();
I think he has two LoadPlayer methods, one in another scene. Otherwise he’d see a hard lock.
OP: go nuts with the Debug.Log() statements, and like I said, even go into the save file and hand edit it, or even faster, put special code that force-changes level to some different value… does it change the behavior? Do you have any other places that do a LoadScene()?