Navigation
Unreal Engine C++ API Reference > Runtime > Engine > Engine
Inheritance Hierarchy
References
Module | Engine |
Header | /Engine/Source/Runtime/Engine/Classes/Engine/GameInstance.h |
Include | #include "Engine/GameInstance.h" |
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
Type | Name | Description | |
---|---|---|---|
![]() |
bool | bReportedPIEStartupTime | |
![]() |
FLatentActionManager * | LatentActionManager | |
![]() |
TArray< TObjectPtr< ULocalPlayer > > | LocalPlayers | List of locally participating players in this game instance |
![]() |
FOnPreClientTravel | NotifyPreClientTravelDelegates | Listeners to PreClientTravel call |
![]() |
FOnUserInputDeviceConnectionChange | OnInputDeviceConnectionChange | Callback for when an input device connection state has changed (a new gamepad was connected or disconnected) |
![]() |
TObjectPtr< class UOnlineSession > | OnlineSession | Class to manage online services |
![]() |
FOnLocalPlayerEvent | OnLocalPlayerAddedEvent | Local player access |
![]() |
FOnLocalPlayerEvent | OnLocalPlayerRemovedEvent | |
![]() |
FOnPawnControllerChanged | OnPawnControllerChangedDelegates | Gets triggered shortly after a pawn's controller is set. |
![]() |
FDelegateHandle | OnPlayTogetherEventReceivedDelegateHandle | Handle for delegate for handling PS4 play together system events |
![]() |
FOnUserInputDevicePairingChange | OnUserInputDevicePairingChange | Callback when an input device has changed pairings (the owning platform user has changed for that device) |
![]() |
FString | PIEMapName | |
![]() |
double | PIEStartTime | |
![]() |
TArray< TObjectPtr< UObject > > | ReferencedObjects | List of objects that are being kept alive by this game instance. |
![]() |
FTimerManager * | TimerManager | |
![]() |
FWorldContext * | WorldContext |
Constructors
Type | Name | Description | |
---|---|---|---|
![]() |
UGameInstance
(
const FObjectInitializer& ObjectInitializer |
Functions
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
int32 | AddLocalPlayer
(
ULocalPlayer* NewPlayer, |
Adds a LocalPlayer to the local and global list of Players. |
![]() ![]() |
void | AddReferencedObjects
(
UObject* InThis, |
|
![]() ![]() |
void | AddUserToReplay
(
const FString& UserString |
Adds a join-in-progress user to the set of users associated with the currently recording replay (if any) |
![]() |
void | Non-virtual dispatch for OnStart, also calls the associated global OnStartGameInstance. | |
![]() |
void | ||
![]() ![]() |
bool | ClientTravelToSession
(
int32 ControllerId, |
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 |
![]() ![]() |
AGameModeBase * | CreateGameModeForURL
(
FURL InURL, |
Call to create the game mode for a given map URL |
![]() ![]() |
ULocalPlayer * | CreateInitialPlayer
(
FString& OutError |
|
![]() |
ULocalPlayer * | CreateLocalPlayer
(
FPlatformUserId UserId, |
Adds a new player. |
![]() |
ULocalPlayer * | CreateLocalPlayer
(
int32 ControllerId, |
Adds a new player. |
![]() ![]() |
void | CreateMinimalNetRPCWorld
(
const FName InPackageName, |
Static util function used by InitializeForMinimalNetRPC and LoadMap to create the minimal world suitable for basic network RPC |
![]() ![]() |
void | DebugCreatePlayer
(
int32 ControllerId |
Debug console command to create a player. |
![]() ![]() |
void | DebugRemovePlayer
(
int32 ControllerId |
Debug console command to remove the player with a given controller ID. |
![]() ![]() |
bool | Return true to delay player controller spawn (sending NMT_Join) | |
![]() ![]() |
bool | Return true to delay an otherwise ready-to-join PendingNetGame performing LoadMap() and finishing up useful to wait for content downloads, etc | |
![]() ![]() |
bool | EnableListenServer
(
bool bEnable, |
Turns on/off listen server capability for a game instance By default this will set up the persistent URL state so it persists across server travels and spawn the appropriate network listener |
![]() ![]() |
ULocalPlayer * | FindLocalPlayerFromControllerId
(
const int32 ControllerId |
Returns the local player assigned to a physical Controller Id, or null if not found |
![]() ![]() |
ULocalPlayer * | FindLocalPlayerFromPlatformUserId
(
const FPlatformUserId UserId |
Returns the local player assigned to this platform user id, or null if not found |
![]() ![]() |
ULocalPlayer * | FindLocalPlayerFromUniqueNetId
(
FUniqueNetIdPtr UniqueNetId |
Returns the local player that has been assigned the specific unique net id |
![]() ![]() |
ULocalPlayer * | FindLocalPlayerFromUniqueNetId
(
const FUniqueNetIdRepl& UniqueNetId |
Returns the local player that has been assigned the specific unique net id |
![]() ![]() |
ULocalPlayer * | FindLocalPlayerFromUniqueNetId
(
const FUniqueNetId& UniqueNetId |
Returns the local player that has been assigned the specific unique net id |
![]() ![]() |
UEngine * | GetEngine () |
|
![]() ![]() |
ULocalPlayer * | Returns the first local player, will not be null during normal gameplay | |
![]() ![]() |
APlayerController * | GetFirstLocalPlayerController
(
const UWorld* World |
Returns the player controller assigned to the first local player. |
![]() ![]() |
UGameViewportClient * | ||
![]() ![]() |
FLatentActionManager & | ||
![]() ![]() |
ULocalPlayer * | GetLocalPlayerByIndex
(
const int32 Index |
Returns the local player at a certain index, or null if not found |
![]() ![]() |
TArray< ULocalPlayer * >::TConstIterator | Returns const iterator for searching list of local players | |
![]() ![]() |
const TArray< ULocalPlayer * > & | Returns reference to entire local player list | |
![]() ![]() |
bool | GetMapOverrideName
(
const TCHAR* CmdLine, |
Find a map override argument on the command-line string (the first argument without a leading '-' or -map=..., whichever comes first). |
![]() ![]() |
int32 | Returns number of fully registered local players | |
![]() ![]() ![]() |
FName | Retrieves the name of the online subsystem for the platform used by this instance. | |
![]() ![]() |
UOnlineSession * | ||
![]() ![]() |
TSubclassOf< UOnlineSession > | ||
![]() |
FOnPawnControllerChanged & | ||
![]() ![]() |
APlayerController * | GetPrimaryPlayerController
(
bool bRequiresValidUniqueId |
Get the primary player controller on this machine (others are splitscreen children) (must have valid player state) |
![]() ![]() |
FUniqueNetIdRepl | Get the unique id for the primary player on this machine (others are splitscreen children) | |
![]() ![]() |
TSubsystemClass * | GetSubsystem () |
Get a Subsystem of specified type |
![]() ![]() |
TSubsystemClass * | GetSubsystem
(
const UGameInstance* GameInstance |
Get a Subsystem of specified type from the provided GameInstance returns nullptr if the Subsystem cannot be found or the GameInstance is null |
![]() ![]() |
const TArray< TSubsystemClass * > & | Get all Subsystem of specified type, this is only necessary for interfaces that can have multiple implementations instanced at a time. | |
![]() ![]() |
UGameInstanceSubsystem * | GetSubsystemBase
(
TSubclassOf< UGameInstanceSubsystem > SubsystemClass |
Get a Subsystem of specified type |
![]() ![]() |
FTimerManager & | ||
![]() ![]() ![]() |
UWorld * | GetWorld () |
|
![]() ![]() |
FWorldContext * | ||
![]() ![]() |
void | HandleDemoPlaybackFailure
(
const UE::Net::TNetResult< EReplayResult >& Result |
|
![]() ![]() |
void | HandleDemoRecordFailure
(
const UE::Net::TNetResult< EReplayResult >& Result |
Called when demo recording fails for any reason |
![]() ![]() |
bool | HandleDisconnectCommand
(
const TCHAR* Cmd, |
|
![]() ![]() |
void | HandleGameNetControlMessage
(
UNetConnection* Connection, |
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 |
![]() ![]() |
void | HandleInputDeviceConnectionChange
(
EInputDeviceConnectionState NewConnectionState, |
Callback for handling an Input Device's connection state change. |
![]() ![]() |
void | HandleInputDevicePairingChange
(
FInputDeviceId InputDeviceId, |
Callback for handling an Input Device pairing change. |
![]() |
void | HandleNetworkError
(
ENetworkFailure::Type FailureType, |
Opportunity for blueprints to handle network errors. |
![]() ![]() |
bool | HandleOpenCommand
(
const TCHAR* Cmd, |
|
![]() ![]() |
bool | HandleReconnectCommand
(
const TCHAR* Cmd, |
|
![]() ![]() |
bool | HandleTravelCommand
(
const TCHAR* Cmd, |
|
![]() |
void | HandleTravelError
(
ETravelFailure::Type FailureType |
Opportunity for blueprints to handle travel errors. |
![]() ![]() |
void | Init () |
Virtual function to allow custom GameInstances an opportunity to set up what it needs |
![]() |
void | InitializeForMinimalNetRPC
(
const FName InPackageName |
Called to initialize the game instance with a minimal world suitable for basic network RPC |
![]() ![]() |
FGameInstancePIEResult | InitializeForPlayInEditor
(
int32 PIEInstanceIndex, |
Called to initialize the game instance for PIE instances of the game |
![]() |
void | InitializeStandalone
(
const FName InWorldName, |
Called to initialize the game instance for standalone instances of the game |
![]() ![]() |
bool | Returns true if this instance is for a dedicated server world | |
![]() ![]() |
bool | JoinSession
(
ULocalPlayer* LocalPlayer, |
|
![]() ![]() |
bool | JoinSession
(
ULocalPlayer* LocalPlayer, |
|
![]() ![]() |
void | LoadComplete
(
const float LoadTime, |
|
![]() ![]() |
void | ModifyClientTravelLevelURL
(
FString& LevelName |
Game instance has an opportunity to modify the level name before the client starts travel |
![]() |
void | NotifyPreClientTravel
(
const FString& PendingURL, |
Broadcast a notification that travel is occurring |
![]() |
void | OnConsoleInput
(
const FString& Command |
Delegate for handling external console commands |
![]() |
FOnPreClientTravel & | ||
![]() |
void | OnPlayTogetherEventReceived
(
int32 UserIndex, |
Delegate for handling PS4 play together system events |
![]() ![]() |
void | This gets called when the player scrubs in a replay to a different level | |
![]() ![]() |
void | OnStart () |
Called when the game instance is started either normally or through PIE. |
![]() ![]() |
void | OnWorldChanged
(
UWorld* OldWorld, |
Callback from the world context when the world changes |
![]() ![]() ![]() |
TSubclassOf< AGameModeBase > | OverrideGameModeClass
(
TSubclassOf< AGameModeBase > GameModeClass, |
Return the game mode subclass to use for a given map, options, and portal. |
![]() ![]() |
bool | PlayReplay
(
const FString& InName, |
Start playing back a previously recorded replay. |
![]() |
bool | PlayReplayPlaylist
(
const FReplayPlaylistParams& PlaylistParams |
Start playing back a playlist of previously recorded replays. |
![]() ![]() |
FGameInstancePIEResult | PostCreateGameModeForPIE
(
const FGameInstancePIEParameters& Params, |
Called as soon as the game mode is spawned, to allow additional PIE setting validation prior to creating the local players / etc... |
![]() ![]() |
void | PreloadContentForURL
(
FURL InURL |
Call to preload any content before loading a map URL, used during seamless travel as well as map loading |
![]() ![]() |
void | ReceivedNetworkEncryptionAck
(
const FOnEncryptionKeyResponse& Delegate |
Called when a client receives the EncryptionAck control message from the server, will generally enable encryption. |
![]() ![]() |
EEncryptionFailureAction | ReceivedNetworkEncryptionFailure
(
UNetConnection* Connection |
Called when a connecting client fails to setup encryption |
![]() ![]() |
void | ReceivedNetworkEncryptionToken
(
const FString& EncryptionToken, |
Handle setting up encryption keys. |
![]() |
void | ReceiveInit () |
Opportunity for blueprints to handle the game instance being initialized. |
![]() |
void | Opportunity for blueprints to handle the game instance being shutdown. | |
![]() ![]() |
void | RegisterReferencedObject
(
UObject* ObjectToReference |
Registers an object to keep alive as long as this game instance is alive |
![]() ![]() |
bool | RemoveLocalPlayer
(
ULocalPlayer* ExistingPlayer |
Removes a player. |
![]() |
void | ||
![]() ![]() |
void | Calls HandleDisconnect on either the OnlineSession if it exists or the engine, to cause a travel back to the default map. | |
![]() ![]() |
void | SetPersistentTravelURL
(
FURL InURL |
Call to modify the saved url that will be used as a base for future map travels |
![]() ![]() |
void | Shutdown () |
Virtual function to allow custom GameInstances an opportunity to do cleanup when shutting down |
![]() ![]() |
void | Starts the GameInstance state machine running | |
![]() ![]() |
FGameInstancePIEResult | StartPlayInEditorGameInstance
(
ULocalPlayer* LocalPlayer, |
Called to actually start the game when doing Play/Simulate In Editor |
![]() ![]() |
void | StartRecordingReplay
(
const FString& InName, |
Start recording a replay with the given custom name and friendly name. |
![]() ![]() |
void | Stop recording a replay if one is currently in progress | |
![]() ![]() |
void | UnregisterReferencedObject
(
UObject* ObjectToReference |
Remove a referenced object, this will allow it to GC out |
Overridden from UObject
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
void | Called to finish destroying the object. |
Deprecated Functions
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
int32 | AddLocalPlayer
(
ULocalPlayer* NewPlayer, |
This version of AddLocalPlayer has been deprecated, pleasse use the version that takes a FPlatformUserId instead. |
![]() ![]() |
FUniqueNetIdPtr | Use GetPrimaryPlayerUniqueIdRepl. | |
![]() ![]() |
PRAGMA_DISABLE_DEPRECATION_WARNINGSvoid | HandleDemoPlaybackFailure
(
EDemoPlayFailure::Type FailureType, |
Now takes a EReplayResult instead. |