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"

Retrieve GameMode and/or GameState in Editor

I'm just trying to retrieve the Game Mode and Game State of the EditorWorld. For some reason it is always returning null.

I have made blueprint instances of my c++ classes for both the AGameModeBase and the AGameStateBase. Then in my Project Settings, I use those instances in maps and modes->Default Game Mode and maps and modes->Game State Class. Then in my UActorComponent, I try to get a handle on these instances like so:

 auto EditorWorld = GEditor->GetEditorWorldContext().World();
 if (EditorWorld) {
     auto GameState = EditorWorld->GetGameState();
     if (GameState) {
         BMoveSetupComponent = Cast<UBMoveSetupComponent>(GameState->GetComponentByClass(UBMoveSetupComponent::StaticClass()));
     }

     auto GameMode = EditorWorld->GetAuthGameMode();
     if (GameMode) {
         BMoveSetupComponent = Cast<UBMoveSetupComponent>(GameState->GetComponentByClass(UBMoveSetupComponent::StaticClass()));
     }

 }

 if (BMoveSetupComponent) {
     BMoveSetupComponent->TestFunction();
 }

However GameState and GameMode are always NULL? I am not sure what to do? This is run while the editor is paused because I enabled the UActorComponent to tick while pause. I'd like to be able to retrieve either of these instances at any time. Is this possible?

Product Version: Not Selected
Tags:
more ▼

asked Aug 14 '17 at 06:14 PM in C++ Programming

avatar image

jchen114
11 1 7 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
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