Save Game on Completing Level

Hi there

I’ve followed at tutorial but my code seems to not be working: Unreal Engine 4 Tutorial | Level Progress & Save Game System - YouTube

I am trying to get my game to save when the player completes the level, so that if the player quits the game, when the player reopens the game, the player can resume the game from the last level that the player is yet to complete.

Based on the Print Strings in the code, it seems that the cast fails in the LevelComplete function in BP_GameMode.

As the code involves multiple Blueprints, I have uploaded a folder that contains all my Blueprint files that are being used for the purposes of this function: https://drive.google.com/drive/folders/10kRNzpnm2cN7aeD_W41gdsgfCFVYjhNl?usp=sharing

I was hoping if someone could spot what I’m missing so that this code starts working. This would be very helpful and thank you in advance for any assistance on this one.

If any further information is required for this question, please let me know.

Cheers
Matt

The stuff in the link doesn’t work because dependencies are missing.

Much better if you just use:

317338-screenshot-1.jpg

Sorry about that mate and thanks for the screenshot.

Here is the packaged project: https://drive.google.com/file/d/1NwlviG2X8S6WZM5n3QmdNjOwk5-bgoap/view?usp=sharing

Hi - ok, I’m looking at this. It seems that most of the level code is in the game mode.

It’s not clear which is your main ( starting ) level and what I need to do, but I’d say part of the problem is that on begin play in the game mode, you’re not referencing the save game at all. Surely you need to read the level index if you want to go back there?

Also your end game func has no slot name in the save game to slot node.

Thanks for the fast response!

I have now added the slot name in the Save Game to Slot node in EndGame func - great pickup there.

I have tried to reference the save game in EventBeginPlay of BP_GameMode, but I’m obviously not doing it correctly as it’s still not working. Could you possibly point out where and how I need to do this? I’m a bit stumped (and I’m still very fresh to Blueprints/coding in general).

Below are some points which hopefully make the project setup look clearer:

  1. The first “level”/main level is the Level in the Maps folder titled ‘MainMenu’
  2. After the player clicks ‘Play’ in the Main Menu, the first playable level is titled ‘001’. The following levels are labelled accordingly i.e. ‘002’, ‘003’ etc.

Thanks for the help and please let me know if you need any more info on this.

Cheers Matt

You also left out the slot name when saving the created save game :slight_smile: When I tested this, it took my machine out, I think there’s a big loop here…

I think this may have been your main problem as it never created the SG.

My build took your machine out?? Sorry, man, that wasn’t my intention lol

Interesting. I can’t seem to find the slot name with the created save game. Are you referring to something in BP_GameMode or the GameSave Blueprint? I’ve taken a look but I can’t seem to find any other slots that have not been named…

In the chunk of code that makes the new save game file, in WBP_MainMenu?

I will try and suss out why it locks up…

Well, it is working now. Main problem was you were never actually creating the save game due to the empty slot name.

Did you get there?

You, sir, are a legend and thank you very much for the assistance! That resolved it. I totally forgot I had a huge chunk of saving code in that Widget Blueprint.

Next step: Link the load game function to the ‘Continue’ button and create a ‘New Game’ button in the Main Menu. Then, create multiple save slots. I will try to figure this out myself/do some research, but if you know of any useful tutorials, please let me know.

Thanks again for the help!

Good stuff.

You don’t need multiple slots, just saving the level number is enough, as you are…