Custom "Game State" never works -

I’m usually pretty good at working things out on my own, but I’m using unreal engine 4.15.1 and the custom game state just…doesn’t work at all.

I’m new to Unreal Engine. I don’t think I’ve ever been able to get anything relating to “game state” to work. Here’s a list of things that I’ve already done -

I’ve created a custom game mode override -

I’ve assigned the new custom game into the level world settings as an override -

I’ve selected my custom state “NewGameStateBase” in the game state dropdown

This is a brand new project with only starter content in it and no custom plugins running -

And it just fails every time.

It doesn’t play anything in event play or event tick. When I cast to game state it fails.

Unreal gives me no indication whatsoever that the game state exists aside from its existence as a file, its existence in the content browser, and it being assigned in the game mode under world settings.

I’m at my wits end. What could I possibly be doing wrong?

If you just created a new GameMode and changed the defaults, you will need to open the new GameMode class and save it. It doesn’t save when changing it from the World Settings before you’ve saved the recently created class once.

After that, maybe you would want to print the name of the current GameState to make sure if its using yours or the default GameState.

Sometimes the GameState takes miliseconds to be created after starting the game, so keep in mind it before trying to print from another class.

In the past, when assigning a new GameMode in the World Settings, I have often had to restart the editor to make it recognize the change.

Hello. Thank you for the replies.

I’ve recently updated the Unreal Editor to the latest patched version. This seems to have fixed it. Perhaps it was a bug? shrug

I’ve noticed few things while working with GameStates:

  • the GameState you specify in the GameMode will trigger it’s begin play event
  • spawning a new GameState (using SpawnActorFromClass) will automatically will replace the previous GameState
  • the new GameState will not trigger its begin play event (maybe it’s a bug that is fixed by now)
  • the previous GameState will not be destroyed automatically, therefore you’ll have to create a reference to it before spawning the new one if you want to get a chance to do something with it
  • I don’t remember how EndPlay events were behaving

If Game Mode and Game State don’t have the same parent class, is not gonna work.
It’s simple as that.
So:

  1. if you create a Game Mode Base, you need also to createa Game State Base.

  2. if you create a Game Mode, you need also to createa Game State.
    blueprint_parent_class_oxido

1 Like