Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Saving a game with multiple levels

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?

Product Version: UE 4.20
more ▼

asked Mar 21 '19 at 04:56 PM in Using UE4

avatar image

16 1 1 4

avatar image Nebula Games Inc Mar 21 '19 at 05:01 PM

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?

avatar image Lepfner Mar 21 '19 at 05:25 PM

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

avatar image Nebula Games Inc Mar 21 '19 at 05:32 PM

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?

avatar image Lepfner Mar 21 '19 at 05:49 PM

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

avatar image Nebula Games Inc Mar 21 '19 at 06:07 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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 alt text

  2. 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.

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

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

  5. 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. alt text

  6. 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 :).

more ▼

answered Mar 22 '19 at 02:00 PM

avatar image

441 4 5 6

avatar image Lepfner Mar 25 '19 at 07:19 PM

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.

avatar image Alekann01 Mar 26 '19 at 12:02 AM

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

avatar image Lepfner Mar 31 '19 at 07:44 AM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question