Loading from menu

Hi all,

I have a BP_SaveGame that contains the variable CurrentLevel which is where I want to update and store the current name reference of the level the character is in which is checked at the point of saving.

The SavePoint is a physical overlap the player hits that runs the save to game slot but it checks the current name of the level and attempts to set it in the BP Save Game in Current Level but it fails, I believe it’s because its trying to convert it from String to Name but the ‘Get Current Level Name’ doesn’t allow me to capture it as a Name

What do you mean by “…but it fails…”? It is not set in the BP_SaveGame or it can’t be retrieved on load or it gives an error?

I don’t have much experience with saving and loading but can’t you just serialize the name as a string?

The level won’t open because something happens in the conversion from String to Name and it fails. I can change the variable to String and that’s fine but now I can’t open the level by Name or Reference based on that variable that is now a string as it was a Name type

image

From the Main Menu the player clicks Start which sets the Current Level in the BP Save Game to ThirdPersonMap

When the player overlaps the Save Point it sets the Current Level to whatever exists in Current Level (ThirdPersonMap) and saves the game

Exit the game and click Load it should load the save from the save point from that level but it fails, I need this to be easily modified so I can load the game from the latest save from the level in which the save was triggered

I just tried converting string to name and opening a menu and it worked for me.

Use PrintString nodes to debug what values are assigned and retrieved from the BP_SaveGame.
(This will also tell you if something does not fire)

This should be working and it looks like it is, but it seems to fail elsewhere.

It seems to fail here when I click the load button, not sure why

This is in fact printing ‘None’ in the PrintString when the game saves when it should have captured the result from Get Current Level Name which is ThirdPersonMap, more testing reveals that Get Current Level Name is getting the correct result, the conversion breaks somehow when it’s being Set

update 1

update 2
no matter what I do it never seems to SET the new Current Level Name variable

this value never changes when I play
image

Being specific to the level name or reference works, but referencing the level name as a variable just isn’t working, doesn’t make sense

Are you sure that the BP_SaveGame variable is set correctly?

Here, can you PrintString the DisplayName of your BP_SaveGame var?

PS:
The FName type is quite involved: FName in Unreal Engine | Unreal Engine 5.4 Documentation | Epic Developer Community
It is entirely possible that you can’t create a new FName because you don’t have access to the FName table. I am really not sure about this but that’s why I urged you to keep the name as a string as long as possible.

I’ve tried it as a string with the same result, fail.

This is from the menu


m

this is from the savegame
image

This is the Savepoint the player overlaps to save game where it should capture, update and store the level name to be pulled when load game is clicked from main menu

From here it seems to have no reference to the save file object in your main menu.

How do you get your BP_SaveGame in the menu?

It looks like you have bp save game object reference as a variable in the save point? Instead try getting game instance, get save game from that, then access the function that should work

Also on load you need to load game from slot before you call open level by name or it won’t reflect the correct information

I think this is what you are after

this is the save game BP

errors

this fails at SET and prints nothing

You need to get the save game object from game instance and set the values that way, a local reference won’t work, also id recommend setting up functions in your save game to set it’s variables

1 Like