UGameInstance

Inheritance Hierarchy

Syntax

class UGameInstance :
    public UObject ,
    public FExec

Remarks

GameInstance: high-level manager object for an instance of the running game. Spawned at game creation and not destroyed until game instance is shut down. Running as a standalone game, there will be one of these. Running in PIE (play-in-editor) will generate one of these per PIE instance.

Variables

Name Description

Public variable

FLatentActionMa ...

 

LatentActionManager

Protected variable

TArray < ULocalP ...

 

LocalPlayers

Protected variable

FOnPreClientTra ...

 

NotifyPreClientTravelDelegates

Listeners to PreClientTravel call

Protected variable

UOnlineSession ...

 

OnlineSession

List of locally participating players in this game instance.

Protected variable

FDelegateHandle

 

OnPlayTogetherEventReceivedDelegateHandle

Handle for delegate for handling PS4 play together system events

Public variable

FString

 

PIEMapName

Public variable

FTimerManager &...

 

TimerManager

Protected variable

FWorldContext &...

 

WorldContext

Constructors

Name Description

Public function

UGameInstance

(
    const FObjectInitializer & ObjectIn...
)

Functions

Name Description

Public function

int32

 

AddLocalPlayer

(
    ULocalPlayer * NewPlayer,
    int32 ControllerId
)

Adds a LocalPlayer to the local and global list of Players.

Public function Virtual

void

 

AddUserToReplay

(
    const FString & UserString
)

Adds a join-in-progress user to the set of users associated with the currently recording replay (if any)

Public function

void

 

CleanupGameViewport()

Public function Virtual

bool

 

ClientTravelToSession

(
    int32 ControllerId,
    FName InSessionName
)

Helper function for traveling to a session that has already been joined via the online platform Grabs the URL from the session info and travels

Public function Virtual

AGameModeBas ...

 

CreateGameModeForURL

(
    FURL InURL
)

Call to create the game mode for a given map URL

Public function Virtual

ULocalPlayer ...

 

CreateInitialPlayer

(
    FString & OutError
)

Public function

ULocalPlayer ...

 

CreateLocalPlayer

(
    int32 ControllerId,
    FString & OutError,
    bool bSpawnActor
)

Adds a new player.

The player which was created.

Public function Virtual

void

 

DebugCreatePlayer

(
    int32 ControllerId
)

Local player access Debug console command to create a player.

Public function Virtual

void

 

DebugRemovePlayer

(
    int32 ControllerId
)

Debug console command to remove the player with a given controller ID.

Public function Virtual

bool

 

DelayPendingNetGameTravel()

Return true to delay an otherwise ready-to-join PendingNetGame performing LoadMap() and finishing up useful to wait for content downloads, etc

Public function

ULocalPlayer ...

 

FindLocalPlayerFromControllerId

(
    const int32 ControllerId
)

Public function

ULocalPlayer ...

 

FindLocalPlayerFromUniqueNetId

(
    const FUniqueNetId & UniqueNetId
)

Public function

ULocalPlayer ...

 

FindLocalPlayerFromUniqueNetId

(
    TSharedPtr < const FUniqueNetId > Un...
)

Public function

UEngine *...

 

GetEngine()

Public function

ULocalPlayer ...

 

GetFirstGamePlayer()

Public function

APlayerContr ...

 

GetFirstLocalPlayerController

(
    UWorld * World
)

Public function

UGameViewpor ...

 

GetGameViewportClient()

Public function

FLatentActio ...

 

GetLatentActionManager()

Public function

ULocalPlayer ...

 

GetLocalPlayerByIndex

(
    const int32 Index
)

Public function

TArray < ULoc ...

 

GetLocalPlayerIterator()

Public function

const TArray ...

 

GetLocalPlayers()

Public function

int32

 

GetNumLocalPlayers()

Public function

UOnlineSessi ...

 

GetOnlineSession()

Online session management object associated with this game instance

Public function Virtual

TSubclassOf <...

 

GetOnlineSessionClass()

OnlineSession class to use for this game instance

Public function

APlayerContr ...

 

GetPrimaryPlayerController()

Get the primary player controller on this machine (others are splitscreen children) (must have valid player state and unique id)

Public function

TSharedPtr < ...

 

GetPrimaryPlayerUniqueId()

Get the unique id for the primary player on this machine (others are splitscreen children)

Public function

FTimerManage ...

 

GetTimerManager()

Public function Virtual

UWorld *

 

GetWorld()

Public function

FWorldContex ...

 

GetWorldContext()

Public function Virtual

void

 

HandleDemoPlaybackFailure

(
    EDemoPlayFailure::Type FailureType,
    const FString & ErrorString
)

Called when demo playback fails for any reason

Public function Virtual

void

 

HandleGameNetControlMessage

(
    UNetConnection * Connection,
    uint8 MessageByte,
    const FString & MessageStr
)

Handle a game specific net control message (NMT_GameSpecific) this allows games to insert their own logic into the control channel the meaning of both data parameters is game-specific

Public function

void

 

HandleNetworkError

(
    ENetworkFailure::Type FailureType,
    bool bIsServer
)

Opportunity for blueprints to handle network errors.

Protected function Virtual

bool

 

HandleOpenCommand

(
    const TCHAR * Cmd,
    FOutputDevice & Ar,
    UWorld * InWorld
)

Public function

void

 

HandleTravelError

(
    ETravelFailure::Type FailureType
)

Opportunity for blueprints to handle travel errors.

Public function Virtual

void

 

Init()

Virtual function to allow custom GameInstances an opportunity to set up what it needs

Public function Virtual

FGameInstanc ...

 

InitializeForPlayInEditor

(
    int32 PIEInstanceIndex,
    const FGameInstancePIEParameters & ...
)

Called to initialize the game instance for PIE instances of the game

Public function Virtual

bool

 

InitializePIE

(
    bool bAnyBlueprintErrors,
    int32 PIEInstance,
    bool bRunAsDedicated
)

Public function

void

 

InitializeStandalone()

Called to initialize the game instance for standalone instances of the game

Public function

bool

 

IsDedicatedServerInstance()

Returns true if this instance is for a dedicated server world

Public function Virtual

bool

 

JoinSession

(
    ULocalPlayer * LocalPlayer,
    int32 SessionIndexInSearchResults
)

Public function Virtual

bool

 

JoinSession

(
    ULocalPlayer * LocalPlayer,
    const FOnlineSessionSearchResult & ...
)

Public function

void

 

NotifyPreClientTravel

(
    const FString & PendingURL,
    ETravelType TravelType,
    bool bIsSeamlessTravel
)

Broadcast a notification that travel is occurring

Protected function

void

 

OnConsoleInput

(
    const FString & Command
)

Delegate for handling external console commands

Public function

FOnPreClient ...

 

OnNotifyPreClientTravel()

Delegate fired when client travel occurs

Protected function

void

 

OnPlayTogetherEventReceived

(
    int32 UserIndex,
    const TArray < const FUniqueNetId & ...
)

Delegate for handling PS4 play together system events

Public function Virtual

void

 

OnSeamlessTravelDuringReplay()

This gets called when the player scrubs in a replay to a different level

Public function Virtual

TSubclassOf <...

 

OverrideGameModeClass

(
    TSubclassOf < AGameModeBase > GameMo...,
    const FString & MapName,
    const FString & Options,
    const FString & Portal
)

Return the game mode subclass to use for a given map, options, and portal.

Public function Virtual

void

 

PlayReplay

(
    const FString & InName,
    UWorld * WorldOverride,
    const TArray < FString >& Additiona...
)

Start playing back a previously recorded replay.

Public function Virtual

void

 

PreloadContentForURL

(
    FURL InURL
)

Call to preload any content before loading a map URL, used during seamless travel as well as map loading

Public function

void

 

ReceiveInit()

Opportunity for blueprints to handle the game instance being initialized.

Public function

void

 

ReceiveShutdown()

Opportunity for blueprints to handle the game instance being shutdown.

Public function

bool

 

RemoveLocalPlayer

(
    ULocalPlayer * ExistingPlayer
)

Removes a player.

Public function Virtual

void

 

Shutdown()

Virtual function to allow custom GameInstances an opportunity to do cleanup when shutting down

Public function Virtual

void

 

StartGameInstance()

Starts the GameInstance state machine running

Public function Virtual

bool

 

StartPIEGameInstance

(
    ULocalPlayer * LocalPlayer,
    bool bInSimulateInEditor,
    bool bAnyBlueprintErrors,
    bool bStartInSpectatorMode
)

Public function Virtual

FGameInstanc ...

 

StartPlayInEditorGameInstance

(
    ULocalPlayer * LocalPlayer,
    const FGameInstancePIEParameters & ...
)

Called to actually start the game when doing Play/Simulate In Editor

Public function Virtual

void

 

StartRecordingReplay

(
    const FString & InName,
    const FString & FriendlyName,
    const TArray < FString >& Additiona...
)

Start recording a replay with the given custom name and friendly name.

Public function Virtual

void

 

StopRecordingReplay()

Stop recording a replay if one is currently in progress

Overridden from UObject

Name Description

Public function Virtual

void

 

FinishDestroy()

Called to finish destroying the object.

Overridden from FExec

Name Description

Public function Virtual

bool

 

Exec

(
    UWorld * InWorld,
    const TCHAR * Cmd,
    FOutputDevice & Ar
)

Exec handler

true if command was handled, false otherwise

References

Module

Engine

Header

Runtime/Engine/Classes/Engine/GameInstance.h