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.
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.
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.
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:
The first “level”/main level is the Level in the Maps folder titled ‘MainMenu’
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.
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…
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.