# Why is my GameState reinitialized with each level load?

**URL:** <https://forums.unrealengine.com/t/why-is-my-gamestate-reinitialized-with-each-level-load/293451>\
**Category:** World Creation\
**Tags:** gamestate, unreal-engine, level, question\
**Created:** [September 11, 2014, 5:43pm UTC](https://forums.unrealengine.com/t/why-is-my-gamestate-reinitialized-with-each-level-load/293451 "2014-09-11T17:43:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArcadeOrigins](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ArcadeOrigins](https://forums.unrealengine.com/u/ArcadeOrigins)\
**Post date:** [September 11, 2014, 5:43pm UTC](https://forums.unrealengine.com/t/why-is-my-gamestate-reinitialized-with-each-level-load/293451/1 "2014-09-11T17:43:34Z")

</div>

When I open a new level, my custom GameState is reinitialised.

The same custom GameState is used for the levels.

I don’t understand why GameState is reloaded ??

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_8ab98422](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8ab98422](https://forums.unrealengine.com/u/anonymous_user_8ab98422)\
**Post date:** [September 11, 2014, 8:17pm UTC](https://forums.unrealengine.com/t/why-is-my-gamestate-reinitialized-with-each-level-load/293451/2 "2014-09-11T20:17:13Z")

</div>

A class is not an object. The object would contain the data, but the object is not the same, it is a new one.

think of a class liek a cookie template and the objects are the cookies. Two can be colored and flavored differently but they both would look like the same cookie. xD

If you are comming from Unity, there is no DontDestroyOnLoad like behaviour in UE4 that I know of. But you could use stream levels and do it this way.

To transport data from one level to another you could either save it to an .ini file if it are just a few variables and cheating is no problem or you could create a binary that is loaded an populates the GameState data again in the next level.

Here is a huge document on this topic and it really depends on what you wanna do serialization.

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

Here is also a nice discussion about this topic

> **[PlayerState persistence across map change](https://forums.unrealengine.com/questions/43814/playerstate-persistence-across-map-change.html)**
>
> So I had some questions about the persistence across map change of PlayerState and talked to JMarkiewicz about it on IRC. I’m posting this for posterity in case someone else is looking for the same answers. Hopefully this quote can help the guys...

---

<div class="post-metadata">

**Author:** ![ArcadeOrigins](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ArcadeOrigins](https://forums.unrealengine.com/u/ArcadeOrigins)\
**Post date:** [September 11, 2014, 9:49pm UTC](https://forums.unrealengine.com/t/why-is-my-gamestate-reinitialized-with-each-level-load/293451/3 "2014-09-11T21:49:02Z")

</div>

Yes… POO rules are not the problem here (and are not a problem 😉 ). The question is only in relation the level persistance of the GameState instance.

Now I know that GameState instance is not persistent. I will see datas saving/loading between levels.

And, at the end of your second link, there is an UE4 guy talking about the new “GameInstance” for levels persistance usage.

And… no, I’m no comming from Unity 😉

Thanks for help.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_8ab98422](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8ab98422](https://forums.unrealengine.com/u/anonymous_user_8ab98422)\
**Post date:** [September 16, 2014, 10:27pm UTC](https://forums.unrealengine.com/t/why-is-my-gamestate-reinitialized-with-each-level-load/293451/4 "2014-09-16T22:27:29Z")

</div>

Cool thanks for the hint. \*\*GameInstance \*\* is brand new, not even in the docs. And it allows to manage state for all players in one place. Pretty sweet.
