Access to game state without cast every time?

I understand concept of GameState, but I feel bit annoyed that I would need to cast it to my class every time I need to read or write variable from it. I have created a macro library blueprint essentially just to wrap around logic for variables stored in the game state. But I am wondering if I can actually store MyGameState instance into some global-ish variable and have access to it from that macro library.

Main thing that is bothering me about this is the need for execution pins whenever I need to cast. Especially for just getting values out of the game state it is rather annoying and not always feasible.


You can convert a cast function pure cast from impure cast. This allows you to leave an execution pin, but also might not be completely safe since you’re skipping the error check an impurecast provides.

See below the image:

Hope this help :slight_smile:

Ok thanks, that’s surely one way, but still feels kinda odd. Would be much easier in my opinion to have some place where I can store casted game state object into variable upon start (since this isn’t going to change in runtime) and then access it directly from other blueprints.

You can maybe create a singleton object? Or store these variables in the game instance or game mode?

Yeah I am kinda expecting it’s heading to C++ land for this. Not sure how game instance or game mode would be useful as I would need to cast those too only to get casted game state :slight_smile: That seems already easier to cast game state right away :slight_smile: