# Where to put Initialization Logic?

**URL:** <https://forums.unrealengine.com/t/where-to-put-initialization-logic/488915>\
**Category:** C++\
**Tags:** gamemode, initialization, unreal-engine, question, CPP\
**Created:** [September 17, 2021, 9:38am UTC](https://forums.unrealengine.com/t/where-to-put-initialization-logic/488915 "2021-09-17T09:38:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AoVPxASehEjjRV](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AoVPxASehEjjRV](https://forums.unrealengine.com/u/AoVPxASehEjjRV)\
**Post date:** [September 17, 2021, 9:38am UTC](https://forums.unrealengine.com/t/where-to-put-initialization-logic/488915/1 "2021-09-17T09:38:54Z")

</div>

hi.

i’m confused in where i should put my game logic, like variable and current game state ( enum ) i saw something about the UGameInstance, it’s that the way to prefer?

actually i’m doing it in GameMode but will be destroyed between levels

---

<div class="post-metadata">

**Author:** ![CtnDev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ctndev/32/1133321_2.png) [@CtnDev](https://forums.unrealengine.com/u/CtnDev)\
**Post date:** [September 17, 2021, 3:10pm UTC](https://forums.unrealengine.com/t/where-to-put-initialization-logic/488915/2 "2021-09-17T15:10:00Z")

</div>

What do you mean by game logic ? Level rules, etc ?

---

<div class="post-metadata">

**Author:** ![AoVPxASehEjjRV](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AoVPxASehEjjRV](https://forums.unrealengine.com/u/AoVPxASehEjjRV)\
**Post date:** [September 18, 2021, 4:46am UTC](https://forums.unrealengine.com/t/where-to-put-initialization-logic/488915/3 "2021-09-18T04:46:30Z")

</div>

i mean, i’m coming from Unity where i used to have a “persistent” Game Controller class that won’t be destroyed between scenes, so i can keep there everything i need to be alive between scenes, from what i understand in Unreal i have two choice, or use “GameMode” in each scene to do my stuff, or just use a “GameInstance” class that it’s a Singleton and i’ll be able to do the same as Unity and GameController right?
