# How can I add a savegame or specific variables?

**URL:** <https://forums.unrealengine.com/t/how-can-i-add-a-savegame-or-specific-variables/279835>\
**Category:** Editor Scripting\
**Tags:** savegame, unreal-engine, question, Blueprint\
**Created:** [April 7, 2014, 5:55am UTC](https://forums.unrealengine.com/t/how-can-i-add-a-savegame-or-specific-variables/279835 "2014-04-07T05:55:07Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Endika](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Endika](https://forums.unrealengine.com/u/Endika)\
**Post date:** [April 7, 2014, 5:55am UTC](https://forums.unrealengine.com/t/how-can-i-add-a-savegame-or-specific-variables/279835/1 "2014-04-07T05:55:07Z")

</div>

How can I save the game or specific variables?

---

<div class="post-metadata">

**Author:** ![tomofnz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tomofnz](https://forums.unrealengine.com/u/tomofnz)\
**Post date:** [April 7, 2014, 9:16am UTC](https://forums.unrealengine.com/t/how-can-i-add-a-savegame-or-specific-variables/279835/2 "2014-04-07T09:16:45Z")

</div>

So far as I’ve got, which isn’t far, there is a **Create SaveGame** , and this makes a .sav file with a named slot. It creates the .sav in UE4’s location /Engine/Projects/ProjectName/Saved/SaveGames/ … at least in my case, but mine never quite does what I want:

When you set variables to be stored, it’ll save something like:  
 CSG\_SaveGameClass\_C _ScoreSAV_ **IntProperty** a _HudVar_ **ObjectProperty** V R /Game/CustomSaveGame/UEDPIE\_0\_SaveDataMap.SaveDataMap:PersistentLevel.CSG\_HUD\_C\_3 None

ScoreSAV and HudVar were my variables, so I guess it found them. But about updating the current value and loading it etc, I haven’t made more progress.

You need to create a specific **SaveGame** class at some point, but I’m not sure exactly how to put it to work. I’m patiently prodding the devs to cook up a tutorial, which they say they will.

In your gamestate class or wherever, you have **SaveGame to Slot** , **Does Slot Exist?** , and **LoadGame from Slot**. Or something similar. Beyond that, I can’t figure it out. Would also love to know more.

Each variable, if you expand it’s properties, has a tickbox for Serialise (which is a coder word for Save using JSon). I don’t know whether the blueprint nodes for SaveGame actually make use of that or not.

---

<div class="post-metadata">

**Author:** ![Arshia001](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Arshia001](https://forums.unrealengine.com/u/Arshia001)\
**Post date:** [April 7, 2014, 9:55am UTC](https://forums.unrealengine.com/t/how-can-i-add-a-savegame-or-specific-variables/279835/3 "2014-04-07T09:55:35Z")

</div>

You will need to create a SaveGame class blueprint specific to your game, and add any variables you need to save into the blueprint. Then, you must add an instance of your SaveGame subclass to the blueprint in which you want to save data.

To save the game, you set any values you need to save in the SaveGame variable, and pass that to the Save Game To Slot node.

To load the game, you call the Load Game From Slot node, cast the return value to your SaveGame type, and get any values you need out of it.

Take a look at the Tappy Chicken sample, it uses this same mechanism to store the player’s highscore.

---

<div class="post-metadata">

**Author:** ![tomofnz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tomofnz](https://forums.unrealengine.com/u/tomofnz)\
**Post date:** [April 7, 2014, 10:41am UTC](https://forums.unrealengine.com/t/how-can-i-add-a-savegame-or-specific-variables/279835/4 "2014-04-07T10:41:21Z")

</div>

Cool! Cool!

---

<div class="post-metadata">

**Author:** ![Endika](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Endika](https://forums.unrealengine.com/u/Endika)\
**Post date:** [April 7, 2014, 11:27am UTC](https://forums.unrealengine.com/t/how-can-i-add-a-savegame-or-specific-variables/279835/5 "2014-04-07T11:27:55Z")

</div>

Thanks. I’ll check it.

---

<div class="post-metadata">

**Author:** ![Endika](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Endika](https://forums.unrealengine.com/u/Endika)\
**Post date:** [April 7, 2014, 1:51pm UTC](https://forums.unrealengine.com/t/how-can-i-add-a-savegame-or-specific-variables/279835/6 "2014-04-07T13:51:52Z")

</div>

The problem here is that the Cast node used in svegame stuff on the flappybird example doesn appear to me. Where can I find it?

---

<div class="post-metadata">

**Author:** ![Endika](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Endika](https://forums.unrealengine.com/u/Endika)\
**Post date:** [April 7, 2014, 1:51pm UTC](https://forums.unrealengine.com/t/how-can-i-add-a-savegame-or-specific-variables/279835/7 "2014-04-07T13:51:52Z")

</div>

The problem here is that the Cast node used in svegame stuff on the flappybird example doesn appear to me. Where can I find it?

---

<div class="post-metadata">

**Author:** ![nopunintendo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@nopunintendo](https://forums.unrealengine.com/u/nopunintendo)\
**Post date:** [April 7, 2014, 2:40pm UTC](https://forums.unrealengine.com/t/how-can-i-add-a-savegame-or-specific-variables/279835/8 "2014-04-07T14:40:55Z")

</div>

The menu for casting objects is context sensitive. If you drag a wire off of the “Tappy Save Game Opject” node, you can then search for the “Cast to [object]” node.

---

<div class="post-metadata">

**Author:** ![nopunintendo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@nopunintendo](https://forums.unrealengine.com/u/nopunintendo)\
**Post date:** [April 7, 2014, 2:51pm UTC](https://forums.unrealengine.com/t/how-can-i-add-a-savegame-or-specific-variables/279835/9 "2014-04-07T14:51:35Z")

</div>

The Tappy Chicken blueprint is very helpful, thanks.

---

<div class="post-metadata">

**Author:** ![Endika](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Endika](https://forums.unrealengine.com/u/Endika)\
**Post date:** [April 7, 2014, 3:11pm UTC](https://forums.unrealengine.com/t/how-can-i-add-a-savegame-or-specific-variables/279835/10 "2014-04-07T15:11:17Z")

</div>

Tried to replicate but the flow stops in my red line.

 ![3413-sin+título.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/8/0/d80a74f0d3f8bb2443795b74fca2c864802608f1.jpeg)

---

<div class="post-metadata">

**Author:** ![nopunintendo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@nopunintendo](https://forums.unrealengine.com/u/nopunintendo)\
**Post date:** [April 7, 2014, 3:47pm UTC](https://forums.unrealengine.com/t/how-can-i-add-a-savegame-or-specific-variables/279835/11 "2014-04-07T15:47:12Z")

</div>

In this screenshot, your “Create Save Game Object” node has an empty “Save Game Class” input, most likely resulting in a failed cast. Otherwise you seem to have a proper implementation of the Tappy Chicken example.

---

<div class="post-metadata">

**Author:** ![mamoniem](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mamoniem/32/1194698_2.png) [@mamoniem](https://forums.unrealengine.com/u/mamoniem)\
**Post date:** [April 12, 2014, 3:53am UTC](https://forums.unrealengine.com/t/how-can-i-add-a-savegame-or-specific-variables/279835/12 "2014-04-12T03:53:22Z")

</div>

I made a tutorial to clear it, and make it simple process, I hope it helps you.

[https://www.youtube.com/watch?v=6l7uynUwm5M](https://www.youtube.com/watch?v=6l7uynUwm5M)

---

<div class="post-metadata">

**Author:** ![ScottSpadea](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/scottspadea/32/1194682_2.png) [@ScottSpadea](https://forums.unrealengine.com/u/ScottSpadea)\
**Post date:** [June 3, 2014, 7:31am UTC](https://forums.unrealengine.com/t/how-can-i-add-a-savegame-or-specific-variables/279835/13 "2014-06-03T07:31:36Z")

</div>

to make a save file, first i created a subclass blueprint of “saveGame” that i called “Omni\_SaveGame” and added a few variables to it. this is where you would add questflag booleans, player stats, inventory items, etc…

then i made a variable in my player controller of type “omni\_saveGame” called “Omni\_SaveData”. this object keeps all of the important variables during gameplay. so loading a game is just copying a file from disk to set this object, and saving is setting the file on disk from this object.

to load a game, i use a “load game from slot” node, then cast it to my custom saveGame type, then use that to set “OmniSaveData” (the member variable in my player controller that holds the data i use during the game)

this image should explain it better:

 ![7615-saveloadgamedata.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/d/d/dddc167f558a91a3a83698e89d5e4bf31bd4ee47.jpeg)
