# Strategy for storing variables across levels

**URL:** <https://forums.unrealengine.com/t/strategy-for-storing-variables-across-levels/342002>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [December 20, 2015, 5:22pm UTC](https://forums.unrealengine.com/t/strategy-for-storing-variables-across-levels/342002 "2015-12-20T17:22:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![edcolmar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@edcolmar](https://forums.unrealengine.com/u/edcolmar)\
**Post date:** [December 20, 2015, 5:22pm UTC](https://forums.unrealengine.com/t/strategy-for-storing-variables-across-levels/342002/1 "2015-12-20T17:22:04Z")

</div>

I failed miserably with my attempt to store variables inside my custom character class. When the level changed, I did not have access to my variables anymore. As a workaround I used a savegame, which worked, but is obviously not ideal.

My objective is to have a place to store variables and have them persist throughout the entire application runtime. I login users on one level, change levels to a play map, then change back once play is complete.

Can anyone point me in the right direction to do the variable storage part? Do I need a custom gamestate? Something else?

Any links to tutorials or documentation on this topic would be welcome.

I’d like to keep this in c++ as much as possible.

Thanks!

---

<div class="post-metadata">

**Author:** ![Pierdek](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pierdek](https://forums.unrealengine.com/u/Pierdek)\
**Post date:** [December 20, 2015, 5:51pm UTC](https://forums.unrealengine.com/t/strategy-for-storing-variables-across-levels/342002/2 "2015-12-20T17:51:05Z")

</div>

> **[Whats the deferent between gamestate and game instance](https://forums.unrealengine.com/questions/189120/whats-the-deferent-between-gamestate-and-game-inst.html)**
>
> whats the deferent between gamestate and gameinstance what we should use for multiplayer UI (UMG) cuz i see some use the gamestate and some use gameinstance

---

<div class="post-metadata">

**Author:** ![edcolmar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@edcolmar](https://forums.unrealengine.com/u/edcolmar)\
**Post date:** [December 20, 2015, 6:04pm UTC](https://forums.unrealengine.com/t/strategy-for-storing-variables-across-levels/342002/3 "2015-12-20T18:04:04Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![edcolmar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@edcolmar](https://forums.unrealengine.com/u/edcolmar)\
**Post date:** [December 20, 2015, 6:08pm UTC](https://forums.unrealengine.com/t/strategy-for-storing-variables-across-levels/342002/4 "2015-12-20T18:08:21Z")

</div>

Just to clarify:

A new instance of the game mode is not created when a level changes?

---

<div class="post-metadata">

**Author:** ![Pierdek](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pierdek](https://forums.unrealengine.com/u/Pierdek)\
**Post date:** [December 20, 2015, 6:15pm UTC](https://forums.unrealengine.com/t/strategy-for-storing-variables-across-levels/342002/5 "2015-12-20T18:15:45Z")

</div>

The new game mode instance is created each time when level changes.

In my opinion you should use GameInstance.
