Nested Save Games

Hi there,

I’m trying to figure out how to create a system that allows me to create a save game of a project, and that project can have multiple configurations associated with it, unique to the project!

I tried creating a save game, called ProjectLevelSave, with inside has another save game inside called ProjectConfigSave, but its just not working as I hoped.

I mean simplified explanation would be creating a save game for each user, and each user can have multiple save files associated with there name.

Any help would be great!

Cheers

After

Why not use multiple USaveGame objects instead of the nesting?

*Edit You could also use a prefix or index matching the user when accessing save data so that one user can only read/write its own save data from within the game. For example you can store 1 USaveGame holding all the player profiles which can be as simple as storing only the player’s name. When “Bob” selects the player profile to be loaded the prefix “Bob_” will be used to filter out all game related save files to only show his save files on the UI. It’s worth checking out how consoles handle savegame data per user as well if that is relevant, because I think consoles like Playstation already handle these cases.

1 Like

Cheers for the reply Roy!

I did think about doing this! Then use the FindFiles node to parse the folder, and filter the results to the correct user to then display on the UI. I just wasn’t sure if there was a better way than having a long list of USaveGame (.sav) files, rather than 1 per user that contained everything inside!

I’d go for the long list of files :slight_smile: imagine if one binary file goes corrupt containing everything. Also, if you want to configure project related settings you could consider storing them in .ini files as well.

You can write .ini very easily in c++ (don’t know about BP):

// FString IniSection
// FString OverallScalabilityLevel;
GConfig->SetString(*IniSection, TEXT("OverallScalabilityLevel"), *OverallScalabilityLevel, GGameUserSettingsIni);

The UGameplayStatics library has a few useful methods to deal with USaveGame objects so you don’t need to implement file access yourself. These are accessible from BP but c++ offers more options.

UGameplayStatics::CreateSaveGameObject
UGameplayStatics::SaveGameToSlot
UGameplayStatics::AsyncSaveGameToSlot
UGameplayStatics::DoesSaveGameExist
UGameplayStatics::LoadGameFromSlot
UGameplayStatics::AsyncLoadGameFromSlot
  • For building UI you could do something like:
//   FString PlayerName = "Bob";
for (int i = 0; i < 100; i++) {
  // make a slot name from Player name + index (slot 0 to 99)
  FString SlotName = PlayerName + FString::FromInt(i)
  if (UGameplayStatics::DoesSaveGameExist(SlotName, 0)) {
    // Add a savegame widget and construct it with the SlotName.
    // Optionally just pull the data to show from the USaveGame.
  }
}
1 Like

Will see how I go at getting it all to filter, trying to stick with BP for now but will fall back to just writing it in C++ if I can’t get optimal results!

Cheers for your input!

Just confirming I got it all working using Blueprints, cheers @Roy_Wierer.Seda145 !