Casting Fail to my GameState

Hi
I’ve set my Gamestate with my Gamemode. Under the world settings as I show here

But when I try to cast to it like this


You’ll see the cast fails

Now I don’t know how with the BPs to do something like check what kind of GameState it is, or any form of debugging. My casts have always worked 100% before, because of the simple way I’ve made my game, so I have no idea of how to check what I am doing wrong.

Is there an in BP way I should be setting my GameState at the start of the game? I thought the defaults of the GameMode covered it

in which bp are you trying to get the game state?

For debugging -> rightclick your cast node an “Add a Breakpoint” then try to start again and move your mouse over the return value of “Get Game State” you can then see if there is
an instance of AGameState at all.

I am trying to get the game state from a BP just in the level. An Actor

I’ve added the breakpoint, I can’t work out how to get that info but I’ll keep trialling. It does say the GameState is not in scope but I don’t get that…

AH HA! Thanks, I worked out it was because I was calling it in the construction script not as event begin play… Now it works!

Thanks

e: Thanks for showing me about breaking points… They will come in handy

yes, that is what i had expected when i ask where are you trying to get the game state.^^

but good for you to solved that :wink:

I was having all my BPs communicate to each other in a ring and then I decided “nah, have the gamestate control everything, and one BP just needs to tell GameState a thing if necessary and it’ll tell everything else”

thats the right spirit :wink:

One Ring to rule them all

hahaha :cool: