Custom Game Instance dont work in Shipping Build

Hi there,

i have a small Problem. In my game i made a custom game instance. This instance is in C++. Then i made from this instance a BlueprintInstance to save values in. This values i use to load at the Level changing.

In the Editor or the standalone mode all works perfect. But if i build a packaged game and Play it, nothing is saved and loaded.

I changed the game instance under Project Settings->modes and maps (?).
In the DefaultEngine.ini it is changed lik this:

[/Script/EngineSettings.GameMapsSettings]
GlobalDefaultGameMode=/Game/SideScrollerBP/NewGameMode.NewGameMode_C
GameInstanceClass=/Game/BrainInstance_BP.BrainInstance_BP_C
GameDefaultMap=/Game/Maps/MainMenu
EditorStartupMap=/Game/SideScrollerBP/Maps/SideScrollerExampleMap
TransitionMap=/Game/Maps/TransLevel

What’s wrong? Why does it work in Editor and standalone but not in the packaged build? Can anyone help me out with this?

Greetings

I’ve made a new blank c++ Project and made the GameInstance in the same way. First as c++ with functions. Then from this i made a blueprint. I set the blueprint as the gameinstance.

With this packaged testgame all works just fine. I dont understand why it doesn’t work with my game.

I thought there was a Problem with a plug in. But in the testgame it works; with the plugins.

Have anyone an idea what cause the Problem? Or is it maybe a bug?

Hi ,

I ran some tests with a new project made in 4.10 and, as you noted, I did not see any problems with a custom Game Instance class not being used in that case. Do you still see the same issue happen in 4.12? If so, would it be possible to get a copy of your project to try to determine why this is happening there?

Hi ,

sorry for the Long delay…

I tested everything and made almost 8 Packaged games. Now i have a solution. It is wierd. If i set in my blueprint a delay (5 seconds) to read from the blueprint after the game starts, then all is working just fine.

My variables are in my Playerblueprint. From that i sent These vars to the gameinstance. After i Change the Level i read them back to the Player. Like i said: in the Editor it worked. I dont know whats wrong. Maybe i did something wrong, but now it is working.

I dont tested 4.12 yet, because i want first to finish my Project. But thank you for looking at my Problem.

EDIT say:
To be sure i made a bool for every Level. Let’s say, if Level 1 true, then save the vars in the gameinstance and update it every 2 or 3 seconds. In the begin Play from my Player i read the first bool from level1. If this bool is true then load the vars. If this is false, then do nothing and wait till Level1 is true. It’s a Little bit strange, but it works ;o)

Hi ,

Would it be possible to get a screenshot of where you are sending the variable information to/from your GameInstance blueprint? I think I may have an idea of what is happening here, but I’d like to see exactly how you have it set up to make sure.

Hi ,

here are the Screens.

Here is a overview from my character blueprint. In the upper left Corner i marked the Settings for the game instance. The first one is called by Event begin Play. Here i check if the first Level is passed. If not, then i set it to passed and the second box is called (from begin Play too).

The second box cast to the gameinstance and set the variables back to my character.

The third box cast to the gameinstance and set the variables i want to use later. I set the vars every second. I tryed every 5 seconds too.

Only with the delay in 3.png loading from gameinstance works. Maybe i missed something.

Thanks for providing the screenshots. I tried again to reproduce the issue using a setup as close as possible to what you are using (without the delay), and again saw no problems with the GameInstance in a packaged game.

I had initially thought that you may be trying to use GameInstance to access data from the Character before the character is actually created, but I no longer think that is the case after seeing what you are doing. I’ll need to poke at this some more next week.

Hi ,

So far I have been unable to reproduce the issue that you described. However, I did have a to discuss the issue with a coworker and he brought me back to my original suspicion that either the GameInstance or the Character were not loaded yet when the attempt was made to transfer data from one to the other. The Engine does not guarantee the order in which elements will be loaded when the game begin, and the fact that adding a brief delay allows everything to work for you seems to point in this direction.

In the setup that I was testing, it seems like the various elements of the game were all loading in an order that allowed me to get by without a delay, but any time you are referring to another Blueprint or class at the very beginning of the game, it is usually a good idea to provide a brief delay to make sure everything is fully loaded.