Save and loading doesnt work in packaged build

Hello!

Everything works fine to save and load in editor, but when I package my game it acts as if theres no save/or it only loads some of it.

I have the code for saving in my Gamemode and I use the same save game for all of the things I save, but putting them under the same save file string name has not worked for me, so I have made a string name for each of the components im saving. I’m currently working therefore with 4 save files, for one saved session.

What could make it not work in packaged build?

I’m aware that the location for the saves for the packaged build is different than in editor, but I can’t seem to understand where to find them or why they won’t load.

Thanks in advance!

Hi Skylene,

In a packaged project your saved games should be at C:\Users\YourUserName\AppData\Local\UE4 Project Name\Saved\SaveGames

There’s also a ‘Get Project Saved Directory’ node that will help you verify this.

My first thought is that you might not have permissions to write to AppData folder. Is your computer/account in a ‘restrictive’ environment? (school or work computer?) - any different results right-clicking on the executable and running as admin?

That’s all I can think of, let us know if that helps.

1 Like

Hello!

Thanks for quick reply!

This is my own personal PC. I’ve gone over to check the permissions, and it seems the only one I don’t have permission for is the one under “special permissions”.

Would that be what I need to allow for it to write to Appdata folder?

‘Special Permissions’ is also unchecked on my PC.

It should “just work” for appdata saving - I did a little googling and found mention reminded me: The creation of the SaveGame (where it checks if one exists and creates one if it doesn’t) should probably be executed in your ‘GameMode’ class. (be sure to set game mode in project settings after creating it) - I believe this is best practice and would help solve any ‘order of operations/execution’ sort of problems.

Cheers

I double checked that Gamemode is set to the right one in the project settings, and it is.

I have also written one of the “load” functions in the gamemode whereas some of the other ones happen in other blueprints on their begin play node. Worth noting they also all share the same SaveGame Blueprint.

Could it be that I need all of the load coding to be in the gamemode and that one is overwriting the other?

Yeah still cant seem to get it working. Everything works fine in Unreal Engine and then nothing loads when I try a packaged built. It does create the save game files though in the C:\Users\YourUserName\AppData\Local\UE4 Project Name\Saved\SaveGames

Okay did some more digging and asked someone else for help. Some things that fixed the issue

  1. Make sure the player has a persistent player ID, so that steam can recognize its ID and save properly. Also giving an ID despite only testing the build before publishing to steam, also fixed some issues on its own.

  2. Having multiple .sav files worked fine in editor, but its not good practice for when building a game. Putting everything into its own .sav file fixed the issue with not everything being loaded , and only some parts.

  3. Other posts also said you should check in the Appdata/local folder for your project and make sure there is a save folder there, and that you have administrative power over your PC, that allows you to write to appdata.

The first and second points fixed it for me, but added the last just incase!

Hope it helps someone in the future!

1 Like
  1. Having multiple .sav files worked fine in editor, but its not good practice for when building a game. Putting everything into its own .sav file fixed the issue with not everything being loaded , and only some parts.

Is this really a thing? Can you give links to this?

Problem for me is that settings such as graphic settings, options the user can toggle need to be in a different file. Or when they start a new game, you’d lose those settings.

Hi! Sorry for late reply.

You can have multiple save files, when saving to slot, by just changing the string name. I found its not good practice for when saving things inside the world, like actors being destroyed, location of things, etc.

But I just recently made a new save file for saving settings. Unreal engine does have a feature built in, to save graphics and such. Here is the tutorial I followed for that sort:

One problem I found though, that is not really addressed in the video, is when you try to save things like audio settings and mouse sensitivity settings. But the same creator, has another video on the audio settings:

For the mouse sensitivity, it depends how you have it set up. If you have it set up like I do, (I have a variable that changes the mouse sensitivity inside my player character. And then that variable is set inside the widget with a slider.) Since my variable is a variable I created, I have to save that to slot like I would with anything else. So for the mouse settings, I have made a new save to slot where it saves that kind of setting since I couldnt find an inbuilt version of it.

Since this post though, like I mentioned before, I have put everything else into one save file. I have only made an exception to the settings that dont save automatically if that makes sense :smiley:

Hey, I seem to be encountering the exact same issue as you - my save/load system is working perfectly in the editor but when packaged it is only saving the odd thing and not the rest. I’ve spent the last couple days trying to fix the issue but seem to be getting nowhere.

Could you let me know in a bit more detail how you fixed the issue? What do you mean by a persistent player ID? I’m only saving to the one .sav file already and there is the correct save folder structure in the app files.

1 Like

Hi!

Persistent player ID just means that you have one ID for the player that is never changed

But I don’t think that was the issue for me. I dont remember exactly, but sometimes when I package and upload to steam, not everything transfers. So I’d recommend a full rebuild when packaging your project.

Aside from that I don’t remember well what fixed it.

Thanks for replying @Skylene1 - I’ll be checking out those videos soon.

1 Like

Hello there!

First of all, Thank you for sharing those with us.
I been having the same problems for about 3 years now (novice here). While everything works fine in editor and actors are saved, package game only saves player location, and destroyed items/actors are not saved.

You mentioned above something about not saving destroyed actors inside the world map? Do you know of any helpful tutorials or if you can please elaborate or explain on how that works? where do you instead save the destroyed actors specifally? I am also not familiar what peristent player ID means (couldnt figure it out online)nor how to set that up.

Thank you in advance for your time reading this and apologies if its much of a trouble! :slight_smile:

Hey! Sorry for the late reply!

Its been a while since this post, so I’ve had a lot of different experiences now with things not saving in packaged games.

Here are a couple of them that I can remember at the top of my head.

  1. I have heard that using delay can sometimes create little hiccups in the system? Like if you use delays wrong and suddenly something fires off at the same time as something else and therefore overwrites the event you actually want?

  2. As for your question about if I know of any tutorials about saving destroyed actors, I don’t know much of any other than the ones I linked before.

My understanding so far of saving deleted actors though is this: You can either choose to save each time the actors are destroyed, or you can choose to save only the remaining actors on the map. I prefer to use the second option as it seems to be the easiest for me to remember though.

So say that we do the second option: Scenario is you have a lot of items in a level that you only want the player to be able to pick up once and never again. So the player picks it up, relogs the game and the item should no longer be there.

What you can do is when you save via a pause screen for example, is make a save event where you use “get all actors of class” and run it through a “for each loop”. Via the “for each loop” pin, you get all the information you want to store.

  1. Get class → saves the item’s class
  2. Get transform → saves the item’s location

And so on.

Now where do you store this information in the save game? You store all the actors information via an array struct. Inside the struct, you want to have a pin for the information you want to store, so one for “class” and one for "transform.

It should look something like this:

(we clear the array every time so that we don’t get duplicates)

To load what you destroyed (items you have already picked up), you would first want to delete every item in the world by using “get all actors of class” running that into a “for each loop” and using “destroy actor”.

Then you want to spawn only the actors that remained (aka the info we stored in that array). Your set up would look something like this:

Now if there are things that have been “half destroyed” in the world, for example trees have been cut but the trunk still remains, you could have a bool variable in your tree blueprint that says “broken”. And set the value to true once the desired part of the tree has been cut. To save that for when you load the game you would just add another pin to your struct thats a bool, and hook it up like you did with the transform and class.

This method seems like the best one for most/if not all my saving cases so far. Yes, using “get all actors of class” is heavier the more actors you have on the map, but I havent really seen much of a performance hit myself when saving up to 5k actors at once.

Hope that makes sense!

  1. Using string = string seems to be tricky sometimes for packaged games to understand. The nodes work perfectly, but where I had an issue was when I was comparing something like a variable with an item name (A) to a self written name (B). The issue here was that when I wanted to have the following branch to read TRUE, it would always go false in packaged games because of one silly thing. Using capital letter.

Heres an image to show what I mean:

image

That setup would work perfectly in the editor, but my experience as of now (I’m using 5.1) , is that when its packaged, it reads the “Weapon” wrong. Its reading A as “weapon” not “Weapon”, (without the capital letter). To summarize, when it comes to using string = string like that, I would advice to never make IDs with capital letters. To debug this, I just packaged the game with a development build and hooked up a print string to the output of the string I’m comparing the value with, to see what it prints, and thats how I found out that it changes the variable to a name without capital letters.

Now I don’t know if this could be applied to persistent player IDs too, but its a good thing to keep in mind I guess?

And for your question about persistent player ID, I am still as of now 100% sure how this works or the logic for it, but if you take the word “persistent” you can think of the word “static”. It NEVER changes. It stays the same.

So when you look at something like the node “get player controller” you will notice that the input pin says “0”. Thats because the default persistent ID I believe, of the player is “0”. So if you have a single player game you wouldnt have to worry about this, but I would assume that if you have a multiplayer game you need to make an ID for each player, like “player 1”, “player 2” etc. or find an ID that is the same (like how steam lets players have usernames and so forth). I wouldn’t take my word for it 100% though, but maybe this can help you look up more about it? And anyone else who knows more, please correct me if I’m wrong and add more information. I would love to know more about it too.

  1. It might be obvious, but ill mention it either way for new devs! If you use streaming levels, you would not want actors that you want to save, to be a part of a streaming level. They should be in persistent level since they need to be loaded when you load the game. Actors that are a part of streaming levels will not save, (because they load and unload whenever players enter certain areas on the map)

I can’t remember much else at this time, but these are some of the things I’ve learned the past few months

2 Likes

Hi there again! :slight_smile: no worries at all regarding the reply,
I totally understand and it is super appreciated that you took so much time to explain all this to me!

Thank you so very much! I am honestly very bad and unfamiliar with all this and pretty much been trying possible solutions online without understanding what Im really doing at most part.
I will study carefully your message and see what I can figure out of this.

Meanwhile I was trying another tutorial :

And this seems to work for packaged game solution at 90% as sometimes random actors seem to re-appear. Would you mind giving me your thoughts on this tutorial above if you ever get a chance? I would like to know if you think its a good practice.

Also, I read about persistent levels and actors in your message and honestly, I think I have badly mapped the game as, I created an entire map for the whole game and using occlussion, lods, etc to “optimize” and having only one load in the start. It works but there is few areas with obvious draw call issues. (Im afraid that’s bad practice but was not able to figure out the streaming throughout the 3 years I been working on this particular project. I am an industry digital artist working for video game companies but I have very limited understanding on how to make something and only following step by step tutorials.)

I cannot thank you enough for offering your help and time, you are very kind and it is for sure highly appreciated!
I will be happy to share any knowledge, although Im afraid there might not be much useful to offer in return hehe.

Wish you all the best! :slight_smile:

1 Like

After searching for so many answers to this question, I found the solution for me:
I had an old save file format that was making my save game load fail. I just deleted it and everything is fine.

The symptoms of the problem were:

  • In the Unreal PIE mode, save games worked fine
  • In the Unreal Windows packaged build, Save Game to Slot and Load Game from Slot didn’t work

My solution:

  • Open Windows explorer
  • Show hidden items (View menu > Show > Hidden items)
  • Navigate to C:\Users<your user>\AppData\Local<your app name>\Saved\SaveGames
  • Delete old save games

What I think was happening:

  • I created an old save game format and there was a save game file there
  • I recently made a new Save Game blueprint (BP_SaveGame), but the Variables didn’t match
  • When I tried to load a save game from slot, that actually worked, but the Cast to BP_SaveGame failed
  • Deleting the old save game file lets Unreal regenerate the file in the correct format