Get current Game Mode from Clients


I’ve an actor in my game (based on the ShooterGame project) that is spawned on a level, and I want to show it only in a specific game mode.

At first I was fetching/testing the current game mode like this:

if (GetWorld()->GetAuthGameMode<AG_CTF_GameMode>()) 

… which was working but only server-side. Then I saw on the AnswerHub that GetAuthGameMode() was only available on the server. I looked for other solutions like testing the GameState instead (I have one gamestate class per game mode) :

AShooterGameState* const GSt = Cast<AShooterGameState>(GetWorld()->GameState);

but GSt is always == NULL. I tried casting it to my custom GameState too (AG_CTF_GameState).

Do you have any hints?


I’ve the same problem.

#Game Mode Only Exists On Server

You can never ever access Game Mode on a client!

It only exists on the server

Use Game State class instead for all your networked needs, it exists on clients and server :slight_smile:


Thanks but this is already what I’m saying in my post. My problem is that GetWorld()->GameState is always NULL on the client.

Did you remember to set your GameState class in your GameMode class?

Do this in your game mode constructor:

 GameStateClass = AYourGameState::StaticClass();

You should be able to access it after that.