RealDocs

AActor::GetGameInstance

function Engine Since 4.4
#include "GameFramework/Actor.h"
Access: public

Description

Returns the UGameInstance that ultimately owns this actor's world. Use this to access game-wide subsystems, persistent state, and custom game instance data.

Caveats & Gotchas

  • A templated overload `GetGameInstance<T>()` exists to cast directly to your custom game instance class, returning null if the cast fails — prefer it over manually casting the result.
  • Returns null if the actor has no valid world. Avoid calling during the constructor.

Signature

ENGINE_API class UGameInstance* GetGameInstance() const

Return Type

UGameInstance*

Example

Access a custom game instance subsystem C++
void AMyActor::BeginPlay()
{
    Super::BeginPlay();
    UMyGameInstance* GI = GetGameInstance<UMyGameInstance>();
    if (GI)
    {
        GI->RegisterActor(this);
    }
}

Version History

Introduced in: 4.4

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.