Hello.
I can’t understand logic of the lifetime of PB variables.
For example, I have some project with:
-
GameInstance BP, that has CurrentCharacter variable (Character)
-
Level SelectCharacterLevel with the SelectCharacterLevelMainWidget. SelectCharacterLevelMainWidget has code, that spawned Character and assigned that Character to the variable GameInstance.CurrentCharacter
-
SelectCharacterLevel also has button, that loads another level CreateCharacterLevel with OpenLevel BP.
-
In EventConstruct of the CreateCharacterLevel there is code, that simply prints values of the GameInstance variables:
Now my issue is:
- When game loaded and pressed button to load CreateCharacterLevel, it’s correctly loaded;
- But I see only value of the some GameInstance variable - UserJsonString (value of GameInstance also assigned in previous level SelectCharacterLevel) and I didn’t see value of the GameInstance.CurrentCharacter.CharName.
- It looks like variables with “basic” types (string, integer) are stored correctly in GameInstance variables, but GameInstance variables with more complex objects, like Characters, are only ‘pointers’ to the objects, that stored in objects, that created them. Ie, as I think, when my SelectCharacterLevel level was unloaded, it’s destroyed character, spawned by SelectCharacterLevelMainWidget and in currently loaded level CreateCharacterLevel and in GameInstance.CurrentCharacter there is only pointer to the destroyed (killed) char.
Am I correct?
Or there is some mistake in my BP code?
Thank you!