x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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!

Product Version: UE 4.9
Tags:
more ▼

asked Sep 19 '15 at 11:44 AM in C++ Programming

avatar image

BramV
386 35 36 78

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

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

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

This way you check if UObject is specific class

 GetWorld()->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

more ▼

answered Sep 19 '15 at 04:59 PM

avatar image

Shadowriver
34k 916 164 1093

(comments are locked)
10|2000 characters needed characters left

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 GetWorld()->GetAuthGameMode();

There is a GetWorld()->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.

more ▼

answered Sep 19 '15 at 01:27 PM

avatar image

Kneebiter
281 15 26 41

avatar image BramV Sep 19 '15 at 04:31 PM

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!

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question