RealDocs

UGameplayStatics::GetGameMode

function Engine Blueprint Since 4.14
#include "Kismet/GameplayStatics.h"
Access: public Specifiers: staticUFUNCTIONBlueprintPure

Description

Returns the current GameModeBase for the world, or null if unavailable. Use this to access rules, scoring, and match state from any actor.

Caveats & Gotchas

  • Always returns null on clients in a multiplayer game — GameMode only exists on the server. Guard all calls with a null check or a HasAuthority() check.
  • Returns AGameModeBase*, not AGameMode*. If your project uses AGameMode (the older class with match state), you must Cast<AGameMode> the result.
  • During the very first tick before BeginPlay fires on the GameMode, this may return null even on the server. Do not call it during very early initialization.

Signature

static ENGINE_API class AGameModeBase* GetGameMode(const UObject* WorldContextObject);

Parameters

Name Type Description Default
WorldContextObject const UObject* Any object in the world to use as context.

Return Type

AGameModeBase*

Example

Access the GameMode safely from an Actor C++
AMyGameMode* GM = Cast<AMyGameMode>(UGameplayStatics::GetGameMode(this));
if (GM)
{
    GM->AddScore(10);
}

Version History

Introduced in: 4.14

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.