Load data from Game Instance

I somehow managed to post this in the wrong forum first and it disappeared so I’ll try again.

I got some great help here just the other day and it got me quite far. I decided to extend something I’m working on a bit and even though I got a great example from a user here that did pretty much this I still can’t figure out why it won’t work for me… I’m clearly overlooking something here…

I simply want to load some transformation data I stored (successfully) in my Game Instance class. I did some ingame print outs (top left) in the first class I fetch transformation info (green) and save it in the Game Instance (pink) and then I try to load it in my Character class construct (orange) but it’s set to the default 0,0,0 there instead of loading the correct value…

Anyway thanks for all the help so far here I’m making slow, slow progress at least.

Hi Sean,

Thanks for the reply! I see, that makes sense.
I’m storing it as soon as I fire up the game so it’d probably be an issue there as you say.
I will try that as soon as I get home.
Thank you!

Hey PhilipK,

When are you storing the transformation data for your character class?

It’s possible that you’re attempting to load the data before it has been successfully stored in terms of order of operations. Try printing the value on BeginPlay instead of Construct and see if you’re getting the correct transform values.

Let me know your results.

Ok so I tried what you said and I initially got the same result but then I tried adding a “delay” function and now it works. This is probably not the most elegant solution :S

The blueprint I save this stuff from is simply a type of “locator entity” that I purely use for it to be easy for me to place a transform in the world and use that to spawn a bunch of different stuff. For that one I also use BeginPlay to save off the transform, would there be a better way to more instantly save off that data or is that the quickest way?

I basically need all this stuff to happen as soon as I load a new map…

Thanks a lot for explaining this and pointing me in the right direction on this, definitely hard to figure out why this was happening.

No problem, glad to help. A lot of the time when you see an issue like this occurring it can just come down to order of operations issues, i.e. the variable is being printed before it’s had a chance to be set. So I’d always recommend either adding a short delay as you’ve done, or moving it to a function that is called shortly after you begin play so that you can ensure that value has been initialized.