Save Game to Slot Failing Intermittently

Hello,
I have a simple save system set up where I create or load it in the GameMode bp,

store the variable and then access it through an interface in other BPs when I need to do a save.

This works around 96% of the time but every once in a while it fails and the data is not saved. I notice it mostly happens when changing levels. This is an open world game so I am doing this a lot. What could I do better to get a 100% rate of my saves happening? Thanks so much for any guidance with this!

It looks pretty sound. The only thing I might query is

image

maybe try

image

( It’s probably not this, but I’ve never tried assuming it exists ).

thanks for this. i made the change but still was able to reproduce the error of it not saving. any other ideas? is there anything i could do to make sure it saves before it continues along in the blueprint? I had a branch statement after the save and on false i delayed a bit, counted up one and tried again until 10 times. but even doing that, i just get a hitch and it still doesn’t save it. so confused what to do here!

one other thing - i notice I get failures a lot more when I am recording my screen in OBS and as a result getting a lower frame rate…so when the computer is working harder on other things the failure rate is higher. I don’t know if that helps anything.

I’m assuming your save game is under 1MB?

It’s basically instantaneous. One frame.

Like I say, what you have here looks ok. Do you have code elsewhere that could be interfering? BTW: don’t use the async save nodes…

My .sav file is 4kb…And yeah…not using the ASync save nodes. Had to learn that the hard way lol.
Here is the rest of my GameMode where I load in everything. It’s open world with a big persistent map and 5 smaller maps so the GameMode first loads in the smaller map, then the player character then removes the loading screen.

Ok, so the game mode should load with the persistent map?

I’m wondering if your save game ref is valid.

Can you put a print string here?

1 Like

Hmm ok I printed out the Save game data. In a stand alone I got “BP_SaveGame_C0” and it saved ok on a few occasions so I did a build. In the build, I got BP_SaveGame_C2147393…(10 digit number) and the first save worked and the 2nd did not but with the same print out.

i’m also noticing that this is very easy to reproduce when i’m recording my gameplay with OBS. It’s much more rare when i’m just playing the game. Are there any work arounds? Like what is the point of the branch coming out of the Save Game to Slot? How could I use that to make sure the data saves?

another thing i notice is when i’m doing things like earning points in the persistent map everything saves fine even when i’m recording with OBS. it’s when i save something and then go to a new level that it’s failing sometimes.

for example, i save my location before going to a new level. (a shop). In the shop things are saved and when I go back to the main level - sometimes the location is not saved (something I saved in the persistent level) or sometimes things I did in the shop are not saved (things I save in that shop level). sometimes it could be both. so it doesn’t matter which level i do the saving…it’s just this going back and forth between levels when it seems to fail.

Thanks for the help with this. Any other ideas?

Ok, new idea.

All the writes are happening, but at some point in your code, you’re writing a fresh save game ( or a previous SG ) over the saved data?..

Is that possible?

Hmmm that’s not likely because:

  1. As far as I know the only place I’m creating the save file is in the game mode in the persistent level
  2. Some things are saved. For example, if I go into the shop with 50 points, when I return it won’t save my location of having gone into the shop (I’ll spawn in a previous save point) but I will have those 50 points still.
  3. The problem doesn’t happen every time. Only sometimes, especially when the computer is being taxed (such as during a screen recording)

I’ll double check, though, that I’m not creating a new save file somewhere else.

Currently i’m going to try the BP below lol. How ridiculous/pointless is this?

I think the only way it can fail is if the reference is not valid.

It’s always 100% rock solid for me ( I know that’s not much use ).

the thing that is killing me is that it’s just not a consistent problem. it only happens sometimes. i’m at a loss what to do besides update the whole project to 5…but last time i did that i had a pretty major frame rate reduction.

I’d modularize your approach. Put all the code to load and save in one place, so it’s not dotted around.

You can have it in the game mode or game instance.

All you ever do elsewhere is get the reference and update it.

You can make an interface call to save it, or let the game mode do it every few seconds, for example.

I think once you have everything in once place, it will be easier to track down.

Thanks. I’m not sure exactly what you mean.
I think I have that already in terms of loading the data,
I used to have it in terms of saving it as well but found that pretty pointless since the interface function was literally just executing that one Save Game to Slot node.

So I get the data from the game mode with an interface, set all the variables I need to from that, and then save the data to slot (with or without the interface it didn’t matter, same errors).

Is there something else I could be doing to get everything in one place?

So you’re only saving in one place?

I’m at a loss really. A google around shows nobody having problems with UE4 and OBS / savegame.

I was yes…I found it didn’t matter if I had the SaveGametoSlot node in the GameMode through an interface or just directly in another BP.
I guess I’ll try some save game systems from the marketplace or something and see if those work any better.
Thanks for the help, though!

1 Like

Tell me if you find it.

The only other thing: If you can condense a couple of levels and your save stuff into a small project, and zip it up somewhere for download. I’ll take a look.

old thread, I know, but google yadayada …

In my case it was caused the QNAP QSync service (backup agent).

I had the same SaveGameToSlot issue, and just wasted three days investigating, debugging, test printing, …
Sometimes it helped to just try SaveGameToSlot like 200 times in a loop, until it worked, but I found no pattern.

The solution:
By simpy killing the QNAP QSync agent all SaveGameToSlot issues immediately vanished, and it worked as intended.

Took three days to recall that I had similar issues e.g. when trying to rename files or folders in the file explorer while that service is processing file in that folder; first it refused the action, but after some time it worked.

The local QSync client constantly scans a configured local path and instantly copies changed files to the QNAP NAS and seems to lock them during that time.
In my case I tagged the whole documents folder including the unreal projects for syncing, causing it to also process the UE sav files.
As I do standard backups anyway, I’ll ditch QSync now as it seems to cause more issues than it prevents. Not recommended for professional environments.

1 Like

Ahhhh I have my whole project in Dropbox so maybe that syncing in Dropbox was/is causing the issue? So once it’s on Steam it might not be an issue? (that seems to be the case so far)

1 Like

Not sure if is is the same issue as yours, basically my save file got corrupted near my final level. When cast to save, it will return fail.

I fixed it by having a backup save but right now, other players are having missing items randomly which could be due to the save issue again. The biggest problem is that i am not able to reproduce the bug.

Unreal save file kinda is bad? I don’t know

1 Like

I’d recommend getting this

You can actually just look at the save games, no debugging. Get these people to send the file to you and take a look at it :slight_smile: