# How to pass variable value when opening new level?

**URL:** <https://forums.unrealengine.com/t/how-to-pass-variable-value-when-opening-new-level/1181022>\
**Category:** Blueprint\
**Tags:** unreal-engine, question, Blueprint\
**Created:** [May 28, 2023, 6:48am UTC](https://forums.unrealengine.com/t/how-to-pass-variable-value-when-opening-new-level/1181022 "2023-05-28T06:48:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hanayosu1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Hanayosu1](https://forums.unrealengine.com/u/Hanayosu1)\
**Post date:** [May 28, 2023, 6:48am UTC](https://forums.unrealengine.com/t/how-to-pass-variable-value-when-opening-new-level/1181022/1 "2023-05-28T06:48:13Z")

</div>

I am trying to setup the enemy’s settings whenever I open a level. My idea was to set it via game state. This works perfectly with default value but now I want to setup new value when I was going to open the level so that it will have different value whenever I open it. Unfortunately, I haven’t found a way to pass these values. The variables that I want to change is marked with blue circle on the image. If possible please give image guidelines since I am still quite new on UE.

 ![encounter](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/4/7/44759e4208dc8755a36c2235e7438eae2ae9720e.png)  
 ![variables](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/9/7/497a983e7b4126dc30b1a3e843edd0d1d47aac9d.png)

---

<div class="post-metadata">

**Author:** ![laggyluk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@laggyluk](https://forums.unrealengine.com/u/laggyluk)\
**Post date:** [May 28, 2023, 7:01am UTC](https://forums.unrealengine.com/t/how-to-pass-variable-value-when-opening-new-level/1181022/2 "2023-05-28T07:01:10Z")

</div>

By default only GameInstance is not destroyed between level changes so it’s a good place to keep persistent stuff, all your other actors get destroyed and then spawned with default data. You can prevent it with some tinkering [Keeping Actors Between Levels - #2 by Crzyhomer](https://forums.unrealengine.com/t/keeping-actors-between-levels/3085/2)

---

<div class="post-metadata">

**Author:** ![Hanayosu1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Hanayosu1](https://forums.unrealengine.com/u/Hanayosu1)\
**Post date:** [May 28, 2023, 7:05am UTC](https://forums.unrealengine.com/t/how-to-pass-variable-value-when-opening-new-level/1181022/3 "2023-05-28T07:05:24Z")

</div>

so there is no way to edit GameState settings during level transition except if we open the level first?

---

<div class="post-metadata">

**Author:** ![laggyluk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@laggyluk](https://forums.unrealengine.com/u/laggyluk)\
**Post date:** [May 28, 2023, 1:44pm UTC](https://forums.unrealengine.com/t/how-to-pass-variable-value-when-opening-new-level/1181022/4 "2023-05-28T13:44:24Z")

</div>

set data in game instance\>change level\> get data from game instance

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [June 27, 2023, 1:44pm UTC](https://forums.unrealengine.com/t/how-to-pass-variable-value-when-opening-new-level/1181022/5 "2023-06-27T13:44:47Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
