Hello, I’m super confused about why I’m unable to set a variable. For context, this has been happening in multiple situations and I’m thinking I somehow am missing something huge that I should know but don’t. So I’m trying to set a variable in the game mode from a widget blueprint. I get the game mode and cast to them (Which is CFL, a function in my common function library for simplicity). So after it’s called, the variable inside the game mode is set. The debug print string I have tells me it’s been set. But then when just a moment later, another function is called that uses that variable, the variable is always it’s default value of one. I don’t understand this. It sets the variable, so why does it change back to the default value? (its instance editable and expose on spawn). Thank you, I would really appreciate some help.
Try it like so:
This would also work:
You’re setting a variable that is local to the function - not the one that belongs to the GM. The moment the function goes out of scope, the value of that variable is also gone. It has to be stored some place less volatile. Perhaps it should belong to the GM, indeed.
1 Like