Lifetime of PB variable

Hello.

I can’t understand logic of the lifetime of PB variables.

For example, I have some project with:

  1. GameInstance BP, that has CurrentCharacter variable (Character)

  2. Level SelectCharacterLevel with the SelectCharacterLevelMainWidget. SelectCharacterLevelMainWidget has code, that spawned Character and assigned that Character to the variable GameInstance.CurrentCharacter

  1. SelectCharacterLevel also has button, that loads another level CreateCharacterLevel with OpenLevel BP.

  2. 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!

Any news?..

“It looks like variables with “basic” types …”

Sounds right.

Still not resolved!..

Yes this is correct and sadly in blueprints there isnt any pretty way to do this, I’ve personally created Structs that save everything my Objects need and remake them when needed from the saved Data using selfmade Serializing Functions

Mopperl,

Agreed, it’s a crap shoot. Right now I have a issue, that I’m setting up an array in order to maintain data (and I’ve done the struct thing you spoke of as well), and walla, it doesn’t maintain the data… It’s the only array that doesn’t, out of what? I have like 20 or so arrays in … and they are all fine.

Oh wait, it does maintain the data… If the “editable” property is true… If it’s false… forget it.

.

Still not resolved…