#How do I make it so that it remembers
1 messages · Page 1 of 1 (latest)
There are multiple reasons. The main one being that a lot of Actors aren't surviving level changes. You can store something like this in a SaveGame, or fwiw in the GameInstance, which survives throughout the whole game process.
There is also the point that you aren't actually saving the result of your CreateWidget anywhere, which will cause the Object to be destroyed after a while by the GarbageCollector.
But I assume you are doing this in the screenshot to retrieve the variable.
That will create a fully, new Widget though
So even if you aren't changing levels, if you would do that code above in a different place, it would still return a none value, cause it's a second instance
You can make your own "GameInstance" Blueprint and assign that in the Project Settings under Maps & Modes at the bottom (iirc).
In that BP you can create a variable to store the LevelName.
In your widget ,when you select the Level, you can do "GetGameInstance -> CastToMyGameInsatnce -> SetLevelName"
And in the screenshow you have there you can do "GetGameInstance -> CastToMyGameInstance -> GetLevelName"
Please don't call your GameInstance "MyGameInstance" though :P