Download

How to know if game is running in either PIE or Standalone mode?

Hi.

I have some code that I only want to execute when the game is running, either in PIE or Standalone mode.




void MyActor::OnConstruction(FTransform transform)
{
    Super::OnConstruction(transform);
    DoSomething();
}

void MyActor::Tick(....)
{
    Super::Tick(...)
    DoSomething();
}

void MyActor::DoSomething()
{
    // .. do something here...
    if (IsPlayingInEditor) { DoSomethingMore }
    else { DoSomethingElse }
}



Obviously this is not the exact code. Is there a global variable or anything I can use to determine if the game is running?

Thanks

Found it - GetWorld().IsGameWorld()

I realize this is late but it may still be useful to others:



if (GetWorld()->WorldType == EWorldType::PIE || GetWorld()->WorldType == EWorldType::Editor)
{
:
}