Download

How to reload from a save game?

I thought that this would be something pretty basic, but is instead turning out to be something that just doesn’t work for me for some reason. What makes it worse is that I cannot find any information anywhere about how to do this. Surely I can’t be the only person that wants to reload from a save game???

I’ve set up my save actor, and I have a button on my UI that saves the game when I click it. It basically just grabs the name of the map, a few other variable values and then saves to a slot. Nothing special. I then have a “load” button that loads that same save slot. From there, I want it to reload the map (either the same map or a different one depending on what was saved to the MapName variable in the save slot). This is where I’m now stuck.

I am trying to use server travel (with seamless travel) to get it to reload the map, but it doesn’t work. By doesn’t work, I mean it goes to a black screen and then just sits there. I’m assuming this black screen is my transition map (which is just an empty map), which is fine. But why does it get stuck there? I have seamless travel ticked in my game mode and I’ve set the transition map in the project settings. I’m also running the game standalone (i.e. not in PIE) since server travel doesn’t work in PIE.

The reason I’m using server travel is because the game can be both single player or multiplayer. When the host reloads the game, I want to make sure it reloads for both the host player and any client players (in a multiplayer game).

Can you show us the Load Button/UMG Blueprint? Help us to help you :smiley:

Sure, but there is nothing much to it yet.

My UMG blueprint literally just calls a custom blueprint node that I made in C++ on my custom game instance. I know I’ve posted in the blueprints forum… but am now posting C++ sorry about that. Guess I didn’t think through very well which forum to post on.


void UMyGameInstance::HandleLoadGame(FString SlotName)
{
	if (UGameplayStatics::DoesSaveGameExist(SlotName, 0) == true)
	{
		SaveGame = Cast<UExSaveGame>(UGameplayStatics::LoadGameFromSlot(SlotName, 0));

		GetWorld()->ServerTravel("/Game/Maps/" + SaveGame->LevelName, true);
	}
}

SaveGame is just an instance of my custom save game actor, which has the variables in it to save information about the game.

One thing I’ve discovered though, is if I turn off Use Seamless Travel on my game mode, then it works fine. The map reloads and both players reset. The only problem is that there is a very long pause… like 5-7 seconds where the game just freezes for both players before resetting. I’m guessing that is the map reloading and all the network traffic going on. The advantage of getting seamless travel to work I’m guessing is that the transition map is being displayed during this pause instead, so you can show a loading screen or something instead of an ugly freeze like this.

The other problem I have though is how do I propagate my SaveGame data to all the actors in the game after reloading the map so they can update their state to match that of the saved game. Do I need to manually pass a reference to the SaveGame to every single actor, or could each actor just call LoadGameFromSlot themselves to read in the save game data. My only concern is, if there is 100 actors, would that mean 100 reads from the disk or does UE4 cache the load game slot for quick in memory access?