Best place to store "global" variables

Hi all,

I just got started with UE4 and I’m trying to wrap my head around the C++ aspect of development. I did some level design and modding for UT3 and UDK a couple years back, but UE4 will take some adjustment. :slight_smile:

Anyway, I was wondering about the best way to create a “global” variable in UE4 (I assume an actual global isn’t the best way to do it :smiley: ). More specifically, I’m wondering where I can put world attributes (e.g. time of day, force of gravity, or who the current president is) so that all other classes I write can access them. Any help is appreciated.


Take a look at GameState:

Hmm, depends what lifetime they need. GameInstance is created when the engine starts to run and remains until the executable exits, so that is as “global” as you’re going to get.