Game instance not working

Hey I created an game instance called “DefGameIns”
And in FirstpersonCharacter_BP here is what I have:


I press L to make lagamcheck true and press H it says ‘true’ I press z to open another level and press h it says false.
I made sure my variables were public and selected the DefGameIns as game instance in the project settings
I really dont know what its causing it

Please help as soon as possible I can’t really continue on with my project.

When you open another level your pawn’s variables are cleared and the pawn is reloaded. You need to save the variable to disk then retrieve it when the pawn loads.

Alternatively you might be able to save it to a HUD class (and assign that HUD in the gamemode), but I think a HUD will reset on level change too and you’ll have the same issue.

Yeah I know it clears the pawn variables but game instances are for that, But mine doesnt seem to be working

Ok I found the Fix if anyone
the problem was When i pressed L it was actually loading it to the instance
But when i pressed H it was printing the old state of the instance instead of the current
so the fix was , before I print string I had to cast again to load the current instance to the pawn and feed the print string

Ah sorry I didn’t realise that was what a game instance was, glad you fixed it.