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

**URL:** <https://forums.unrealengine.com/t/how-to-know-if-game-is-running-in-either-pie-or-standalone-mode/145498>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [June 10, 2020, 8:39am UTC](https://forums.unrealengine.com/t/how-to-know-if-game-is-running-in-either-pie-or-standalone-mode/145498 "2020-06-10T08:39:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_ddf68e01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_ddf68e01](https://forums.unrealengine.com/u/anonymous_user_ddf68e01)\
**Post date:** [June 10, 2020, 8:39am UTC](https://forums.unrealengine.com/t/how-to-know-if-game-is-running-in-either-pie-or-standalone-mode/145498/1 "2020-06-10T08:39:26Z")

</div>

Hi.

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

```auto

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_ddf68e01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_ddf68e01](https://forums.unrealengine.com/u/anonymous_user_ddf68e01)\
**Post date:** [June 10, 2020, 9:59am UTC](https://forums.unrealengine.com/t/how-to-know-if-game-is-running-in-either-pie-or-standalone-mode/145498/2 "2020-06-10T09:59:54Z")

</div>

Found it - GetWorld().IsGameWorld()

---

<div class="post-metadata">

**Author:** ![Jerry.Richards](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jerry.Richards](https://forums.unrealengine.com/u/Jerry.Richards)\
**Post date:** [September 22, 2020, 5:55pm UTC](https://forums.unrealengine.com/t/how-to-know-if-game-is-running-in-either-pie-or-standalone-mode/145498/3 "2020-09-22T17:55:54Z")

</div>

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

```auto

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

```

---

<div class="post-metadata">

**Author:** ![AlexPfaffe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AlexPfaffe](https://forums.unrealengine.com/u/AlexPfaffe)\
**Post date:** [September 1, 2023, 1:18am UTC](https://forums.unrealengine.com/t/how-to-know-if-game-is-running-in-either-pie-or-standalone-mode/145498/4 "2023-09-01T01:18:12Z")

</div>

Isn’t thel bool GIsEdito;r’ variable meant for this?

---

<div class="post-metadata">

**Author:** ![frankiezafe](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/frankiezafe/32/732708_2.png) [@frankiezafe](https://forums.unrealengine.com/u/frankiezafe)\
**Post date:** [November 23, 2023, 12:18pm UTC](https://forums.unrealengine.com/t/how-to-know-if-game-is-running-in-either-pie-or-standalone-mode/145498/5 "2023-11-23T12:18:03Z")

</div>

> [@Jerry.Richards](#):
>
> `GetWorld()->WorldType == EWorldType::Editor`

was exactly what i needed, thanks!

---

<div class="post-metadata">

**Author:** ![Cracklings\_3D](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Cracklings\_3D](https://forums.unrealengine.com/u/Cracklings_3D)\
**Post date:** [January 23, 2025, 3:27am UTC](https://forums.unrealengine.com/t/how-to-know-if-game-is-running-in-either-pie-or-standalone-mode/145498/6 "2025-01-23T03:27:33Z")

</div>

Bumped into this problem, so I tried to search for how the engine does this internally. And here it is:

```auto
// Engine/Source/Editor/TurnkeySupport/Private/TurnkeyEditorSupport.cpp
bool FTurnkeyEditorSupport::IsPIERunning()
{
#if WITH_EDITOR
    return GEditor->PlayWorld != NULL;
#else
    return false;
#endif
}

```

Unfortunately this is private code in module, but copy paste always works (=

P.S. Just realized OP wanted to rule out Standalone mode as well. The code above only checks PIE. But I’ll leave it here anyway, just in case.

---

<div class="post-metadata">

**Author:** ![Nizami\_Nz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nizami\_Nz](https://forums.unrealengine.com/u/Nizami_Nz)\
**Post date:** [September 15, 2026, 10:49am UTC](https://forums.unrealengine.com/t/how-to-know-if-game-is-running-in-either-pie-or-standalone-mode/145498/7 "2026-09-15T10:49:25Z")

</div>

Free plugin for it…

> **[Game State Check](https://www.fab.com/listings/7b0d3c0e-c385-4aad-be7b-44883964d39d)**
>
> This product will expand your blueprint functionality. It adds important validation functions that you can use in any blueprint.This product contains useful functions that will tell you the state of the game or engine.Technical...
