Hi!
I created a save game blueprint and i use it in game pause menu for saving and loading data. It’s look nice but when i want to load all data from main menu it’s only opening game level and not changing (e.g. player location or player health it’s just reseting). But when i click load game from pause menu it’s setting up saved player location and other stuff.
Check out the screenshots how it’s look like in editor. Mayby someone can tell me what im doing wrong.
Save game blueprint:
Pause menu save game button Part1:
Pause menu save game button Part2:
Pause menu load game button:
Main menu load button Part1:
Main menu load button Part2:
That’s all, I hope someone will help me.
first try out the reroute node it will help make things more readable. it will help you to organize all the connections.
ok as for your actual issue i imagine the issue lies with the fact that your loading the level after setting all your character variables. whenever you load a new level everything gets destroyed including your character, the only thing that survives is the game instance. so you would be better off to either load the level then get the save data for the rest of the things, OR load all the data, save it to the game instance, then load then level, and transfer all the game instance data to the character and such.
it actually wouldn’t be to hard to accomplish either. lets say you elect to get the save data again on loading the level. ok so from the main menu you would get the save, set a variable in the game instance telling which save was last loaded, then load the level. in the new level you could have a script in the game instance on begin play, get the last loaded save data, and set the health and such on the player.
I spend a few hours on this but actually i have no idea how to repair this and i completely don’t understand how game instance work. I try to do something stuff with game instance but i don’t know how to connect that with Save Game blueprint that would save this things when i loading the level. In Save Game blueprint i have string named SaveGameSlot and i use it when i loading game from slot. So in game instance i created same one and i try to connect that with Main Menu widget but i have no idea how should i do that. I don’t know whether should i delete all Main Menu load game button and create everything from begin or should i just remake this a little bit.
ok so lets forget the game instance part for now, you only really need that if you are using multiple save slots (can work on that later). i assume that your using the same gamemode bp for every level. if thats the case then in the menu widget just have the open level functionality and dont worry about the character stuff we will move that part to the gamemode. next open your game mode bp (create one if you need to and set it to be used in the project settings). in the game mode, from the on begin play event load the save data and copy over the rest of the script you had in the menu widget, everything from the load to the set location. that should get you working.
now ill try to explain why this wasn’t working before and now should work. lets say you have two levels; mainMenuLevel and Level01. when each level is opened it had its own character that was created and that only existed in that level, so one character in MenuLevel and another in Level01. the way you previously were attempting to set the character attributes you were targeting the character that existed in the menuLevel, then you were opening a new level which destroyed the MenuLevel character and created a new character for the new level01.
ok so the way i just instructed you to try out using the game instance. for this method we take advantage of the fact that a new game mode is created whenever a new level loads so that you are always targeting the character that exists in the current level. so when the game mode is created upon loading a level it runs the script which loads the save game data and affects the current character.
heres a example of what i mention above.
the top half of the picture is the game mode bp, here is where you are getting the values to apply to the character and actually applying them. this is on begin play so it will run at the beginning of the level just before the play starts.
the bottom half shows the main menu widget where all you really need to handle is getting the save game and loading a level. i made the level to be loaded as part of the save game object so you could potentially save the players progress in the game as they progress through.
Thank you very much, now i understand this better and everything works fine.