Saving not working, doesn't load the right level

I have a save data struct containing data like the player’s position and the name of the level the player saves in. I then use the Load Level Instance (by Name) to load the save if I need to (the only thing attached to that function is the level name, nothing else).
Everything seems to be getting saved. The problem is that, for some reason, if I save in one level and then decide to load that save while I’m in a different level, the saved level doesn’t load. It just resets back to the level I was in when I decided to load. I know that the level name is properly saved because I make sure to have a print string function that prints the saved level’s name whenever I click on load, so I don’t think that’s the issue.
Any thoughts?

There isn’t really anything we can say since you’ve provided very little information on your specific case.

You’re saying everything is fine, but it’s not working; that means something isn’t fine.
Please provide extensive images on related functions and the like so we can find the exact root of this problem for you.

Ah, understood. Here is my load event



And here is my save event

These are both activated from the pause menu, which is what the ‘Remove Pause Screen’ is for at the end of the load event

Two things I see.

First: In your load function, you have the delay before the loading. This means that you won’t actually see any loading screen when loading. You’ll see the loading screen, but it’ll only start loading after it has finished.

Second, the actual problem: You’re using load level by name. This is only for streaming levels. For normal level loading, use the open level node.
image

1 Like

Thank you, it works! The right level is now loading. However, now the player transform seems to be resetting, and its position after loading a save is now back to the position it was in at the start of the level before saving. I tried to use Set Actor Location instead of Set Actor Transform in the Load Event, but that still doesn’t work.

Just a tip- you don’t need to get actor of class every time you want to reference your player. You can use get player pawn. If you just need to do something that all pawns have like setting the location, you can leave it with just get player pawn, and if you need to do something to the player itself, you can then cast it (right click the cast node and convert to pure cast to not require any exec pins)

Yeah it’ll still think you’re in the other world. The easiest way to fix that is by migrating the function into your game instance:

Make sure to add a >=0.1 second delay after loading the level like so:

You can create a game instance by creating a new blueprint class and searching for it:




You can then activate it by going into project settings and changing Game Instance Class from GameInstance to whatever you just made.


So I went ahead and made a separate GameInstance class and moved the Save and Load events to there, but unfortunately, I’ve just been getting errors during runtime.

Saving seems to work, but if I decide to load the save, it just gets stuck on the loading screen.

You should read the errors. They’re very helpful. Those underlined sections can be clicked on to take you right to the errored node (the left-most underline is the most relevant on each given error).

In this case it seems either the save doesn’t exist, you didn’t load the save (therefor the reference to it doesn’t exist) or you loaded the wrong slot (which isn’t saved to and therefor doesn’t exist).

As well as that, for some reason you don’t have a valid reference to your player? Not sure how. Make sure the player is actually spawned in that level.

1 Like

Thank you so much for your help! For some reason my save reference wasn’t getting read after moving the load event over to the GameInstance bp, but all I had to do was re-add the node where it casts to the SaveGameData BP. Works great now

1 Like