Hello Community,
looks like i just ran into a problem that 's so simple, nobody ever had it before.
Its about storing a simple integer in a custom Game Instance for transfering it to another level.
I did the following Steps:
-
Make a new blueprint from class game instance, called MyGameInstance
-
Set in Project Setting, Maps and modes, the Game instance to MyGameInstance
- Making a new Variable within MyGameInstance called x, integer, “open the eye”, editable.
- In Player charakter, ( side scroller in my example from side Scroller example project) making a variable y, integer.
- On begin play, get game instance and cast it to MyGameInstance, print string to see if cast was successfull.
- Promote the Cast output to Variable, called My Game Instance
- On Event Z, set y by adding “1” to it and print y as string.
- Get the MyGameInstacne reference, get X from MyGameInstance, add 1 to it, and set X from MyGameInstance to the new value. ( I first tried to put in y directly into x, but in that tutorial, they did it that way: Blueprint Game Framework Basics | Live Training | Unreal Engine - YouTube)
- Print x as string
in this Screenshot, i tried again to get Y directly into X, but outcome is still the same.
Also having a basic open level node, on event K, to change levels in both of the level blueprints, pointing to the other level.
So, when i start the game in editor (also tried stand alone), i get the string that everything worked well on the casting. but wenn i hit Z, which incerements X and Y, and printing a string of both, i see that it works on Y ( the variable within the character) but not on X ( variable in MyGameInstance). Of course, after changing a level, its counting again from zero, while x still stays zero. and the accessed none of property error also occures while playing.
the funny thing is i think i make everything like they tell us in the tutorials and documentation, but somehow i can’t get it to work. Looks like im missing something so obvioous, nobody ever ran into that problem. I must confess, im not an programmer, and have only a little understaning of scripting.
Would be kind if somebody tells me what i am doing wrong.