Hello colleagues, I need your help in solving a seemingly simple but obscure issue. I’m having trouble loading my saves when changing levels …
I have a structure in which I save my character’s variables (health, equipment, level …), I store it in SaveGame, in GameInstance I created two functions responsible for saving and loading character variables. There are two levels in my game. Level 1 (main menu) and level 2 (game level). These levels have different game modes. When I test saves at level 2 (game level), they work fine, so I concluded that there is no bug in them. The problem occurs when I want to load saves from level 1 (main menu). Every time I load my saves I get the start of a new game.
I tried:
initialize the character, then cut it out because I didn’t get the desired effect and got a lot of errors. In the process, I came to the conclusion that it is not very necessary since I have a single-player game;
I tried to study level streaming, but all the examples that I found were done within the boundaries of one level (the level was simply divided into separate zones);
Tried to figure out the teleport function, but couldn’t get it to work;
At the moment my level loading looks like this
Hello @Auran131, could you please indicate which parts of the code you want to look at?
Now, when I try to load a saved game from the main menu, I get errors (for all variables in the structure), if I load at the game level, then there are no such errors.
The errors refer to “ContinueGame” which is located in the Game instance (here I load the slot and set the values of the character variables from the saved structure)
if you only have one player character you can just store its savedatastructure directly in the gameinstance, then on the character begin play you can check if that save data exists and load directly from the gameinstance
I was just thinking about this and will try it out right now. I also managed to find information that you cannot change the game mode during execution from the blueprints (not 100% sure, but several threads on the forum indicate this).
Found the solution here I have trouble with load game button in main menu - #5 by ThompsonN13
In short, it’s about loading your saves in a game mod. I did this by using a boolean variable, when I start the game I set it to true, if I continue the game I set it to false. In my game mod, when starting, I check the value of a variable and select the desired branch.