Saving a game with multiple levels

Huh? By “Scene 1” do you mean “Level 1”? And if so, are you basically trying to figure out how to open up levels because that is what it sounds like. So press a button, load Level 1 from Level 2 or the main menu? Yes?

1 Like

Hello, I’m trying to create a save/load system for my game. I have seen multiple tutorials online, but none of them help when it comes to saving the game with multiple levels. Here is an example of what I want to achieve:
-If the player saves the game on Scene 1, I want him to be able to load that scene from another level and from the main menu using a load save widget. Can anybody help please?

I’m sorry I didn’t express myself fully. I do mean level 1 by scene 1 and if the player saves the game in that level I want the game to remember his location and rotation throughout the game

Let’s put it at this. I want to create a save/load game that will work with multiple levels

Isn’t that how every save/load works? That is the point of saving…so you can start at level 3 or 4 or 5 instead of 1 each time you play. Each level thus is able to initiate a save cycle. I still don’t understand the basic concept. Sorry.

So basically your player will be able to play levels in parallel? Like you play level 1, end at point A, then decide to load up level 2 end at point B. Then you close the game come back want to play level 1 again and start at point A instead of the beginning of level 1? Is that what you are trying to do?

For something like this, you would want the save game functionality be accessible by any map, so the GameInstance would be the best place to Save / Load since it remains persistent throughout your game.
I would recommend you storing your level specific information in a struct and store it as a map in your save game object.

  1. Create a level information structure and add the desired properties. You can do this by right-clicking in your content directory → Blueprint ->Structs

  1. Create a custom Game Instance class or open your game instance if you have one already. Be sure when you create your custom Game Instance you update your project settings to use this custom Game Instance class.

  2. Create a custom Save Object class and all your struct as a map with a string key.

  1. In the custom, GameInstance class create an event you can call to save your game for the current level.

  1. Create an event you can call to load your save information. This will check to see if we have any information saved about the current map.

  1. Amend your current logic in your game to use these two functions created, by using GetGameInstance → CastToMyCustomGameState → (Get the name of the function).

You will obviously modify the structs so it contains whichever data you would like. Note, because I used a map, this means you will only be able to save one set of data per level. If you want to have multiple saves per level you will have to modify the way the data is saved and how it is accessed.

I hope this helps. I quickly rushed this on my lunch break without testing, so if this code doesn’t work directly, it will at least give you an idea of what we are trying to achieve.

Good luck :).

3 Likes

Sorry for not replying for the past couple of days I have been very busy. I will try this tomorrow when I have time and I will let you know. I think your idea might work with a little modification.

No problem mate, be sure to let me know if you’re still encountering issues :slight_smile:

Sorry for not replying, I had some issues with the Game Instance Class but now it works. Thank you very much