Download

Is a referenced variable live, or just a localised copy of it?

Hi all,

Just a little something i’m struggling to get my head around.

I’ve an array in my GameInstance, where i am storing any variables i might need to access globally.

What I am doing is in a separate blueprint, casting to it (As game instance), getting the variable i need, and creating a local variable to that blueprint. I thought this would give me a direct link to that original variable in GameInstance, but when i’ve been modifying it, none of the changes are actually being sent up to it, but are just being done locally.

Am i missing a trick here, is that how it is supposed to work, and if so, how would i create that link back without casting lots and lots of times?

Well you almost confused me too XD

You dont need to cast to gameinstance more than one time, than you can promote that to a variable “MY_GameInstance”.
This will save the "id or adress " of the gameinstance, and you will be able to access anything inside the gameinstance, all the variables and structures and events…
So , cast to the gameinstance, promote it a variable and everywhere Drag “MY_GameInstance” in the blueprint pin out and type “Get-AnyVariable” or call any event.

Beware that if you promote to a variable any of the variable inside the Gameinstance like My_custom_scorepoints,
You will end with just another variable, with the same value but unlinked to the original.

Here and there you will see some value when you set variables
like : float is a number
instead Actor variables are “Actor reference” they not store the actor but a quickline to access that actor!

Yes just tried and it was exactly this. Thanks for the help :slight_smile: