I have just published new tutorial on how to use the new Engine feature called the Game Instance class!
This is only in the engine as of 4.4, but it is very powerful!
You can use the Game Instance class to store data between level transitions!
So where previously you might have had to save stuff out to config file or use a save object, or write out to binary file, now you can carry data from one level to another using the Game Instance class!
In the example code on the wiki I show you how to count the total number of ticks that have elapsed since your game application window first opens and the first level is loaded! The count keeps rising even after changing levels multiple times!
You can now store any data you want between levels!
Epic Wiki Link
**Sample Code From Wiki**
's the code where I am using a custom Game Instance class to count the number of total ticks that occur in the PC, even across different levels!
```
void ASolusPC::PlayerTick(float DeltaTime)
{
Super::PlayerTick(DeltaTime);
USolusGameInstance* SGI = Cast<USolusGameInstance>(GetGameInstance());
if(SGI)
{
SGI->InterLevelPersistentValue++;
VShow("Inter level value is now!", SGI->InterLevelPersistentValue);
}
}
```
Essential Tip
To use a custom Game Instance you need to set your DefaultEngine config file!
Yes it is, I am using a Game Instance for all my persistent data serialization. Serializing the state of all objects between levels. Allowing the world to appear persistent. A lot of fun.
Nice one! With this one and the GameSingleton (through the GameSingletonClassName config value) we have a lot of freedom regarding persistent instances.
Thanks dude! Yeah ditching UnrealScript was the best decision ever made I have been using UE3 for about 8 years and I also tended to implement stuff in native then script, you just get more from the engine.