How to check which game mode is active?

Hi There,

Currently I have two different game modes active. Inside an actor, I want to know which of those two is currently active, because the actors needs to do different things depending on the current game mode.
How can I see which of the two different game modes I created is currently active?

Thanks a lot!

I’m not entirely sure why you would have two game modes going at once - Unreal doesn’t currently have support for changing the GameMode at runtime.

Generally speaking, you can get the active game mode using ()->GetAuthGameMode();

There is a ()->SetGameMode(), but it generally shouldn’t be called directly. Typically, you set the game mode class in your project settings or the world settings for the map, and the engine creates an instance for you.

Can you explain a little more about how and why you’re using two game modes? Maybe I can offer more useful information if I understand that.

You get game mode as said and then how compire UClasses, theres 2 ways

()->GetAuthGameMode()->GetClass() == AGameMode::StaticClass();

This way you check if UObject is specific class

()->GetAuthGameMode()->IsA(AYourGameMode::StaticClass());

Its the same but diffrence is it also returns true if class is not inputed class but related to it, so if you input AGameMode it would always return true.

Obviuesly you can use that on any UObject not only AGameMode

I’m currently doing a stress test on some aspects of the game. Therefore I created a different gamemode and gamestate for this test, however I am reusing some actors from the normal game, and these need to do some additional things when the stress test is running. That’s why I want these actors to be able to detect whether I am running in the normal game mode or the stress-test game mode / game state. I don’t change the gamemode during runtime.

Thanks!