Game State doesn't spawn at level start (4.12.3)

I’ve got a Widget called GameHUD. It’s created by my Player Controller at Begin play and added to Viewport.

The binding a Text in the widget to game state doesn’t work.

As you can see my game mode is set to have a GS Game state, but casting the gamestate to GS in the Widget fails.

This used to work in 4.10 so I think it’s a bug.

Hey ,

Just for debugging purposes, try putting a delay after the Event Construct of a second or two to see if it’s possible that the Game State is returning null because it doesn’t exist yet. Let me know the results of that test and then we can continue to investigate from there.

In the screenshot I was showing event construct. But that was debugging. It won’t work on key presses from player controller either. Game state is the default one.

Also, the problem is that I’m using a binding function in my Widget. If the gamestate doesn’t exist yet how can the binding work? Do I have to put an isValid for every time I try to cast gamestate?

It’s always worth using an IsValid node just to prevent any null references.

Have you overriden the Game Mode in the World Settings at all? Try creating a new Game Mode and set your Game State in that one instead, seeing if that makes a difference.

So if I create a brand new level, and override the gamemode in the world with a new one (via “+” icon) it doesn’t work either. But if I open that new game mode and hit compile then it works. I’m sure this was working before in 4.10 without having to go and compile the blueprint.

I’m not sure that I’m understanding the issue, as compiling the blueprint before it will work properly seems like expected workflow to me.

Can you provide some repro steps that we can use to reproduce this issue in a clean project? That will give more context and help me ensure I’m understanding the issue correctly.

Ok

  • Create a new level, create a new game mode override and a new game mode
  • Create a new player controller for that game mode
  • Observe that it gets spawned properly at the start of the level.
  • Create a new Game State for that game mode
  • Observe that it does not get spawned at the start of the level.

96527-db2.png

Here are the steps I’ve taken:

  1. Create a new level
  2. Create a new game mode
  3. Set it in the World Settings as the Game Mode Override
  4. Created a new Game State
  5. Set it in the Game Mode
  6. In the game state, added a print string (The Game State Has Spawned)
  7. In the level blueprint, I used a get game state node and printed that as well

In both 4.11.2 and 4.12.4, the game state was printing those messages on begin play as expected. Is there a step that I am missing which is causing me to be unable to reproduce your issue?

Your steps look correct. I’m just not seeing that on 4.12.3. Is there anything else I can produce to help you reproduce it?

Try 4.12.4, as that is the version that I am working in and it’s possible that there was an issue that was resolved.

So I’ve updated to 4.12.4 and same deal.

World override has a GS gamestate class
when it spawn, it will NOT print hello (I can see other prints working fine)

96656-s1.png

96657-s2.png

Interesting, it’s still working on my end.

Did you ensure to save your level before doing this? Also, have you ensured to save and compile all related blueprints?

I can’t reproduce it on a clean project using 4.12.4. So, well, I will try delete all my saved/binaries/intermediate and give it another go.

This can be closed. Seems it is working now. Seriously no idea why it wouldn’t work last week. Thanks Sean Flint for trying to reproduce it.