# Question about "Global Variables".

**URL:** <https://forums.unrealengine.com/t/question-about-global-variables/2031632>\
**Category:** Blueprint\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [September 21, 2024, 7:11pm UTC](https://forums.unrealengine.com/t/question-about-global-variables/2031632 "2024-09-21T19:11:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ImagineTheEnding](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ImagineTheEnding](https://forums.unrealengine.com/u/ImagineTheEnding)\
**Post date:** [September 21, 2024, 7:11pm UTC](https://forums.unrealengine.com/t/question-about-global-variables/2031632/1 "2024-09-21T19:11:57Z")

</div>

Hello,

Again I am new and use a visual scripting program called Adventure Creator. So, now that I am using Unreal it’s just super different and I am trying to get accustomed. In Adventure Creator if you want a global variable, all you have to do is mark it as global. Then it can be used anywhere in the game.

However, for Unreal it seems a lot more complicated. From what I understand there aren’t “Global Variables” I followed this tutorial, but I get stuck at some point. [How create global variable?](https://forums.unrealengine.com/t/how-create-global-variable/286785)

 ![Question02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/0/6/2063dd82d2e6988379a98fc5031bd31425d37c38.jpeg)

I feel like what I did was wrong, or I am not understanding something.

I also tried following this tutorial but got lost. [https://www.youtube.com/watch?v=HPVUMQ3Y7DY](https://www.youtube.com/watch?v=HPVUMQ3Y7DY)

Could someone explain further? Images and examples are very helpful. I watch Unreal tutorials but they’re sort of fast paced. If anyone knows a more slow paced tutorial for this, let me know. They just go from one thing to another without explaining what anything really means.

---

<div class="post-metadata">

**Author:** ![SupportiveEntity](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SupportiveEntity](https://forums.unrealengine.com/u/SupportiveEntity)\
**Post date:** [September 21, 2024, 8:05pm UTC](https://forums.unrealengine.com/t/question-about-global-variables/2031632/2 "2024-09-21T20:05:25Z")

</div>

Hey there @ImagineTheEnding! So Unreal’s paradigms avoid things like global variables, as they have always been more work to maintain in the long run and worse when scaling games. I personally often recommend creating a new `GameInstance` and using that to hold your variables that you need to access globally.

`Gameinstance` are active and maintain data through the entire play session and you can access it from anywhere. This is often where I place saving/loading functionality and data for the session.

Nawrot’s setup over here is probably the closest simple way to keep a global that is maintainable, but it would still suffer from the scale issues if you end up needing more ways to manipulate that variable itself.

> [@How do you make 'Global' variables?](https://forums.unrealengine.com/t/how-do-you-make-global-variables/1840221/9):
>
> You can make functions in function library, and store that “Global” variable in game mode or game instance. First make bp game mode and your variable inside of it: variable declaration in BP\_Game\_Mode (create this blueprint based on game mode class, add variable) [my global variable] Second, make Blueprint Function Library. And make those 3 functions inside: Get Game mode (this is mainly to make SINGLE point/code in case you want to store those global variables elsewhere, also single poi…

Here’s also a video showing how to make a new `gameinstance` and create variables on it that might make the transition a bit clearer:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/4/f/34f8ae6d44e26a28b4c2a6c7631c96584a8c576b.jpeg "How to Create a Game Instance in Unreal Engine 5 - Carry Data Between Levels") ](https://www.youtube.com/watch?v=sWh1jgHb6Tw)

**Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.**

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [September 22, 2024, 11:37pm UTC](https://forums.unrealengine.com/t/question-about-global-variables/2031632/3 "2024-09-22T23:37:17Z")

</div>

Depending on the use case you could create a Replicated Actor placed in the level that contains said variables. Having only the Game mode or Game State govern their values (Set).

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/4/6/c46b16a63377f1e517977e8eab079d80ec598aab.jpeg)

Each class that needs access to these variable would have to get a reference to the actor and save a copy ref.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/9/e/e9ed6718872164f13444256a70daa65cb322ae7a.png)

Usage of “Globals” imo aren’t recommended.

---

<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:** [October 22, 2024, 11:37pm UTC](https://forums.unrealengine.com/t/question-about-global-variables/2031632/4 "2024-10-22T23:37:44Z")

</div>

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