Save & Load System

You should learn how to save a custom settings option value (variable) and how to load it, How to save and load a gameplay variable (token, health, armor..)

Save & Load Gameplay Variables

In this section, we’ll learn how to save and load gameplay variables. A gameplay variable refers to any variable used during gameplay (e.g., armor, health, location, time, etc.).

📁 Save A Gameplay Variable

To explain this, I’ll demonstrate how to save a variable called Armor (int) to show how the system works and how to save your own variables.

Armor variable inside my character (i want to save this variable)

1 Create The Desired Variable Inside The Save Class

Create a copy of the variable you want to save inside the Full_Modern_Menu_Save Save Class, and set its category to Gameplay Variables.

This is my armor variable inside the save class

If If your variable has a default value, make sure the one in the Save class matches the original.

2 Add Your Variable To The Save Function

Inside ConfirmSaveGame_WB, there is a function called Save Game Variables To A Slot. This function transfers data from the local variable to the one in the Save class. Use a cast to your desired Blueprint class to get your local variable, then set its value to the Save class variable using the blue reference line that points to the Save class instance.

Since my Armor variable is in my character, I performed a cast to my character to get the Armor value and assign it to the corresponding variable in the Save class.

Now the gameplay variable (armor in this case) is saved in the slot that player would select

📂 Load A Gameplay Variable

You’ve saved your variable, but how do you actually load it when the player selects Load Game where this variable was saved?

1 Load The Variable Inside The Game Component

Variables loading is handled by the component because the component is designed to work as a game mode, you alraedy added the component to your game mode so the component is already acting like a game mode, inside it there is a function called Load GameData, now we do the opposit, we need to get the variable from the save class (there is a blue line with reference to save class in the function) and then give its value to the local variable.

i called my player character and give the local armor variable inside my character the value of the save class armor variable

Save & Load Settings Variables

🧰 Settings with console variable

Console variables settings mean settings that apply using the console commands like: r.AntiAliasingMethod or r.MaterialQualityLevel are saved in the Engine.ini file and loaded automaticaly when game launch.

Engine.ini is located in Your_Project_Name\Config\DefaultEngine.ini when in editor mode. And For packaged game the Engine.ini file is located in C:\Users\YourLocalName\AppData\Local\Your_Project_Name\Saved\Config\Windows\Engine.ini

The FMM has ready blueprint functions to save your own settings console variables

Exemple to help you understand how to use these very usefull Nodes to save your new setting option.

Engine.ini with some Cvars with their values as exemple

In this picture, the section is /Script/Engine.RendererSettings. Each key represents a console variable, such as r.AntiAliasingMethod or r.MaterialQualityLevel. The value assigned to each key corresponds to the value that the console variable should hold. For example, the anti-aliasing method uses an integer value, the RHI uses a string value, and sharpness uses a float value.

To Read the value of these CVars (Console Variables) to show it in the new option in menu simply use build-in Get Console Variable Value Functions :

Choose the right node for the compatible variable value that your CVar hold.