Cannot Cast to Custom Game State

I am trying to access a variable in my custom game state but when I try to ‘get game state’ and then ‘cast to game state’ with it, I can only see the base ‘GameState’ object that the engine provides.

This is the error:

I have updated the world settings / default settings to have my custom game mode / game state:

I see from tutorials / other threads that you should see the actual game state you defined in world settings when you cast. My desired behavior is like below:

correct behavior

I have been stuck on this a while so please let me know if you have any ideas - i would really appreciate it.

PS: I’ve tried creating new blueprints, levels, restarting engine, etc. but nothing seems to work.

You have to drag from the ‘as game state’ pin, and search for your variable.

Thank you for the response!

I tried to do this and i can see the ‘get chosen variable’ but when I select it, the nodes are not connected. When I try to connect the nodes I have the same exact situation as my first screenshot.

Just solved it on my own…silly mistake.

When you do ‘cast to game state’ you need to actually cast to your custom game state, ie: ‘Cast to [CUSTOM_GS]’ and then get game state and plug it in. I was trying to cast to the base game state, so the output was always just that base game state with no values inside it.

You have to drag from the ‘as game state’ pin, and search for your variable.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.