In my example below, I am reading PIT101 from MyGI however I’d really like to return the value of the variable contained in TagName.
Any help would be really appreciated as I’ve been trying to do this for days without success.
I guess you should write a getter function in GameInstance instead of trying to get directly the variable.
Something like : float GetMyValue(FName VariableName).
You then would have to write the logic, perhaps a Switch to return the correct value.
Thanks for your assistance silkik1. I’ll try to write a function, but unless I’m missing something, this will still require me to use switch or something similar, as you suggested, in which case I’ll need to specify a switch comparison with Name, which will defeat what I’m trying to do.
I need to be able to get the function to return the value of the variable defined by Name (the variables are stored in my GI variables list) but I don’t want to have to hard code a comparison. I just want the function to try to return the value and if it doesn’t exist to return an error.
Does this make sense?
Try to create a Map (type of array) in game instance.
The Values of a Map are referenced via a key string… in your case, a name… that could help you as Workaround for a getter function.
This doesn’t really happen in blueprint, not easily anyway. You just actually get the variable.
Thanks so much for your help BDC_Patrick. Maps were exactly what I needed.
I’ve made a bool Map and a Float map and I can now reference them by name.