Which objects to store which bits of save game blueprints?

Sudo-Ku
Sun, 11 Jul 2021 17:38:05 +0000
Editor Scripting

(not sure what happened to my other question that was awaiting mod review for the last 3 days, so I’ll add this in the meantime as it’s related)…

I’m new to working with save game files and I think I understand the basic idea, although I’m struggling to determine exactly which bits of logic I save in which blueprints and how to communicate between them without replicating anything. I’m using the gameinstance to pull/push data to the save game slots, then send it back to other blueprints in the game.

The game is a soloplayer rpg that allows a max of 3 save game slots per user account (1 slot per character). I’ve created a custom save game blueprint containing the list of variables that need to be stored with default values to begin along with a custom game instance blueprint.

On the main start menu screen blueprint are buttons to load up each of these 3 slots if/when they are created. Plus a button to delete each one. A button underneath that searches for the next free slot and creates a save game file for that slot (or returns an error if they are all taken). Then the player is sent to the create character set of menu screens.

On the create character menu screen, the player picks a race to play as, then the ‘Next’ button saves that data to the ‘CharRace’ variable in that slot. If the player clicks on the ‘Back to Main Menu’ button, it searches for any slot where the ‘CharFate’ variable is still set to ‘Unknown’ (default value) as Fate is the last variable to be changed when a new character is created. If any are still saved as ‘Unknown’ then that slot is deleted. All the ‘Back to Menu’ buttons in the character creation process have this event run, as it assumes the character wasn’t completed and the slot should therefore remain free to re-use.

The player then goes to the Appearance screen, where they select physical details. Each of these buttons will update the relevant variables in the save game slot. Then they enter their character’s name. Again, there is a ‘Back to Main Menu’ button which will delete an incomplete character.

On initial login, the same lookup/delete event is run in case of random shut down during character creation.

The last screen is where a random variable is assigned called ‘CharFate1’ when ‘Accept Fate’ button is clicked. Then the start game animation is run and the player enters the game world.

I also want to update the button text on the saved game slot buttons on the first menu screen to match the character name the player enters later on.

During the game (open world), there are various triggers that update the game slot variables in the background. This uses a variable called ‘ActiveSlot’ with values 1-3 that is created when the character creation process begins and/or when one of the slot buttons is clicked and the player continues their game. The ‘ActiveSlot’ value is reset to ‘0’ on initial log in.

My problems all seem to be based on the issue of where to store which bits of the logic for the above as well as how to read data from the slot and get these values to use as part of other events. For example, the logic on updating the variable ‘Race’ when clicking ‘Next’ - should the core part of the event be stored on the gameinstance blueprint and just an on-click event created in the menu screen that runs this? Or do I add that in the create character blueprint (if so, how?). I’m guessing the answer to that will determine most of the issues with the above.

It is searching for a free slot and creating a save game file in the UE folder when I begin the create new character process (although I’m unsure if the default variables are being saved, as the ‘Back to Main Manu’ button event based on the ‘CharFate1’ default value is failing). I can also delete slots via the menu buttons, so I’m happy that bit is working.

For saving the current location in the open world map, do I create this logic in the gameinstance or in the thirdpersoncharacter blueprint? When I started out, I was trying to keep everything in the gameinstance and just include events for button on-click to run the event. But I’ve seen a lot of conflicting opinions in tutorials, so I’m even more confused now!

1 post - 1 participant