Navigation
API > API/Runtime > API/Runtime/Engine
Each player that is active on the current client/listen server has a LocalPlayer. It stays active across maps, and there may be several spawned in the case of splitscreen/coop. There will be 0 spawned on dedicated servers.
| Name | ULocalPlayer |
| Type | class |
| Header File | /Engine/Source/Runtime/Engine/Classes/Engine/LocalPlayer.h |
| Include Path | #include "Engine/LocalPlayer.h" |
Syntax
UCLASS (Within=Engine, Config=Engine, Transient, MinimalAPI)
class ULocalPlayer : public UPlayer
Inheritance Hierarchy
- FExec → UPlayer → ULocalPlayer
- UObjectBase → UObjectBaseUtility → UObject → UPlayer → ULocalPlayer
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
ULocalPlayer
(
const FObjectInitializer& ObjectInitializer |
Engine/LocalPlayer.h | ||
ULocalPlayer
(
FVTableHelper& Helper |
DO NOT USE. This constructor is for internal usage only for hot-reload purposes. | Engine/LocalPlayer.h |
Classes
| Name | Remarks |
|---|---|
| FOnControllerIdChanged | |
| FOnPlatformUserIdChanged | Event called when this local player has been assigned to a new platform-level user |
| FOnPlayerControllerChanged | Event called when this local player has had a new outer PlayerController set |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| FOnPreBeginHandshakeCompleteDelegate | TBaseDelegate_NoParams< void > | Engine/LocalPlayer.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| AspectRatioAxisConstraint | TEnumAsByte< enum EAspectRatioAxisConstraint > | How to constrain perspective viewport FOV | Engine/LocalPlayer.h |
|
| bEmulateSplitscreen | bool | Whether or not we're emulating splitscreen with this player. | Engine/LocalPlayer.h | |
| bSentSplitJoin | uint32 | Set when we've sent a split join request | Engine/LocalPlayer.h |
|
| CachedUniqueNetId | FUniqueNetIdRepl | The FUniqueNetId which this player is associated with. | Engine/LocalPlayer.h | |
| LastViewLocation | FVector | The location of the player's view the previous frame. | Engine/LocalPlayer.h | |
| Origin | FVector2D | The coordinates for the upper left corner of the primary viewport subregion allocated to this player. | Engine/LocalPlayer.h | |
| PendingLevelPlayerControllerClass | TSubclassOf< class APlayerController > | The class of PlayerController to spawn for players logging in. | Engine/LocalPlayer.h | |
| Size | FVector2D | The size of the primary viewport subregion allocated to this player. 0-1 | Engine/LocalPlayer.h | |
| ViewportClient | TObjectPtr< class UGameViewportClient > | The primary viewport containing this player's view. | Engine/LocalPlayer.h |
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| ConnectionIdentifier | int32 | Engine/LocalPlayer.h | ||
| ControllerId | int32 | The controller ID which this player accepts input from. | Engine/LocalPlayer.h | |
| OnControllerIdChangedEvent | FOnControllerIdChanged | Engine/LocalPlayer.h | ||
| OnPlatformUserIdChangedEvent | FOnPlatformUserIdChanged | Event called when platform user id changes | Engine/LocalPlayer.h | |
| OnPlayerControllerChangedEvent | FOnPlayerControllerChanged | Event called when the outer player controller changes | Engine/LocalPlayer.h | |
| PlatformUserId | FPlatformUserId | The platform user this player is assigned to, could correspond to multiple input devices | Engine/LocalPlayer.h | |
| SubsystemCollection | FObjectSubsystemCollection< ULocalPlayerSubsystem > | Engine/LocalPlayer.h | ||
| ViewStates | TArray< FSceneViewStateReference > | Engine/LocalPlayer.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual FSceneView * CalcSceneView
(
FSceneViewFamily* ViewFamily, |
Calculate the view settings for drawing from this view actor | Engine/LocalPlayer.h | |
virtual bool CalcSceneViewInitOptions
(
FSceneViewInitOptions& OutInitOptions, |
Calculate the view init settings for drawing from this view actor | Engine/LocalPlayer.h | |
virtual void CleanupViewState
(
FStringView MidParentRootPath |
Clear cached view state. | Engine/LocalPlayer.h | |
void ForEachSubsystem
(
TFunctionRef< void(TSubsystemClass*)> Operation |
Performs an operation on all Subsystem of specified type, this is only necessary for interfaces that can have multiple implementations instanced at a time. | Engine/LocalPlayer.h | |
FUniqueNetIdRepl GetCachedUniqueNetId() |
Retrieves this player's unique net ID that was previously cached | Engine/LocalPlayer.h | |
int32 GetConnectionIdentifier() |
Get the client connection identifier for this local user. | Engine/LocalPlayer.h | |
int32 GetControllerId () |
Returns the controller ID for the player. | Engine/LocalPlayer.h | |
UGameInstance * GetGameInstance() |
Get the game instance associated with this local player | Engine/LocalPlayer.h | |
virtual FString GetGameLoginOptions () |
Retrieves any game-specific login options for this player if this function returns a non-empty string, the returned option or options be added passed in to the level loading and connection code. | Engine/LocalPlayer.h | |
int32 GetIndexInGameInstance() |
Returns the index of this player in the Game instances local players array | Engine/LocalPlayer.h | |
virtual int32 GetLocalPlayerIndex () |
Returns the logical local player index where 0 is the first LocalPlayer that was created. | Engine/LocalPlayer.h | |
virtual FString GetNickname() |
Retrieves this player's name/tag from the online subsystem if this function returns a non-empty string, the returned name will replace the "Name" URL parameter passed around in the level loading and connection code, which normally comes from DefaultEngine.ini | Engine/LocalPlayer.h | |
bool GetPixelBoundingBox
(
const FBox& ActorBox, |
This function will give you two points in Pixel Space that surround the World Space box. | Engine/LocalPlayer.h | |
bool GetPixelPoint
(
const FVector& InPoint, |
This function will give you a point in Pixel Space from a World Space position | Engine/LocalPlayer.h | |
FPlatformUserId GetPlatformUserId() |
Returns the platform user that is assigned to this player | Engine/LocalPlayer.h | |
virtual int32 GetPlatformUserIndex () |
Converts the platform user id to an index where 0 is the first logged in user. | Engine/LocalPlayer.h | |
virtual FUniqueNetIdRepl GetPreferredUniqueNetId () |
Retrieves the preferred unique net id. | Engine/LocalPlayer.h | |
virtual bool GetProjectionData
(
FViewport* Viewport, |
Helper function for deriving various bits of data needed for projection | Engine/LocalPlayer.h | |
FReply & GetSlateOperations () |
Getter for slate operations. | Engine/LocalPlayer.h | |
const FReply & GetSlateOperations () |
Engine/LocalPlayer.h | ||
virtual TSharedPtr< FSlateUser > GetSlateUser () |
Get the SlateUser that this LocalPlayer corresponds to | Engine/LocalPlayer.h | |
virtual TSharedPtr< const FSlateUser > GetSlateUser () |
Engine/LocalPlayer.h | ||
TSubsystemClass * GetSubsystem () |
Get a Subsystem of specified type | Engine/LocalPlayer.h | |
TArray< TSubsystemClass * > GetSubsystemArrayCopy() |
Get all Subsystems of specified type, this is only necessary for interfaces that can have multiple implementations instanced at a time. | Engine/LocalPlayer.h | |
ULocalPlayerSubsystem * GetSubsystemBase
(
TSubclassOf< ULocalPlayerSubsystem > SubsystemClass |
Get a Subsystem of specified type | Engine/LocalPlayer.h | |
virtual FUniqueNetIdRepl GetUniqueNetIdForPlatformUser() |
Retrieves this player's unique net ID from the online subsystem using the platform user Id | Engine/LocalPlayer.h | |
FUniqueNetIdRepl GetUniqueNetIdFromCachedControllerId() |
This should be deprecated when engine code has been changed to expect FPlatformUserId UE_DEPRECATED(5.x, "Use GetUniqueNetIdForPlatformUser instead") | Engine/LocalPlayer.h | |
virtual UWorld * GetWorld() |
Get the world the players actor belongs to | Engine/LocalPlayer.h | |
bool HandleDNCommand
(
const TCHAR* Cmd, |
Exec command handlers | Engine/LocalPlayer.h | |
bool HandleExecCommand
(
const TCHAR* Cmd, |
Engine/LocalPlayer.h | ||
bool HandleExitCommand
(
const TCHAR* Cmd, |
Engine/LocalPlayer.h | ||
bool HandleListAwakeBodiesCommand
(
const TCHAR* Cmd, |
Engine/LocalPlayer.h | ||
bool HandleListMoveBodyCommand
(
const TCHAR* Cmd, |
Engine/LocalPlayer.h | ||
bool HandleListPawnComponentsCommand
(
const TCHAR* Cmd, |
Engine/LocalPlayer.h | ||
bool HandleListSimBodiesCommand
(
const TCHAR* Cmd, |
Engine/LocalPlayer.h | ||
bool HandleListSkelMeshesCommand
(
const TCHAR* Cmd, |
Engine/LocalPlayer.h | ||
bool HandleMoveComponentTimesCommand
(
const TCHAR* Cmd, |
Engine/LocalPlayer.h | ||
bool HandleToggleDrawEventsCommand
(
const TCHAR* Cmd, |
Engine/LocalPlayer.h | ||
bool HandleToggleStreamingVolumesCommand
(
const TCHAR* Cmd, |
Engine/LocalPlayer.h | ||
virtual void InitOnlineSession() |
Called to initialize the online delegates | Engine/LocalPlayer.h | |
bool IsPrimaryPlayer() |
Determines whether this player is the first and primary player on their machine. | Engine/LocalPlayer.h | |
FOnControllerIdChanged & OnControllerIdChanged() |
Engine/LocalPlayer.h | ||
FOnPlatformUserIdChanged & OnPlatformUserIdChanged() |
Engine/LocalPlayer.h | ||
FOnPlayerControllerChanged & OnPlayerControllerChanged() |
Engine/LocalPlayer.h | ||
virtual void PlayerAdded
(
UGameViewportClient* InViewportClient, |
Called at creation time for internal setup | Engine/LocalPlayer.h | |
virtual void PlayerAdded
(
UGameViewportClient* InViewportClient, |
Called at creation time for internal setup | Engine/LocalPlayer.h | |
virtual void PlayerRemoved() |
Called when the player is removed from the viewport client | Engine/LocalPlayer.h | |
virtual void PreBeginHandshake
(
const FOnPreBeginHandshakeCompleteDelegate& OnComplete |
Allow local player to run any async tasks needed before starting travel to a server. | Engine/LocalPlayer.h | |
virtual void SendSplitJoin
(
TArray< FString >& Options |
Send a splitscreen join command to the server to allow a splitscreen player to connect to the game the client must already be connected to a server for this function to work | Engine/LocalPlayer.h | |
virtual void SendSplitJoin
(
TArray< FString >& Options, |
Same as SendSplitJoin() above but with additional arguments. | Engine/LocalPlayer.h | |
void SetCachedUniqueNetId
(
const FUniqueNetIdRepl& NewUniqueNetId |
Sets the players current cached unique net id | Engine/LocalPlayer.h | |
void SetConnectionIdentifier
(
const int32 Id |
Set the connection identifier for this local user. | Engine/LocalPlayer.h | |
virtual void SetControllerId
(
int32 NewControllerId |
Change the physical ControllerId for this player; if the specified ControllerId is already taken by another player, changes the ControllerId for the other player to the ControllerId currently in use by this player. | Engine/LocalPlayer.h | |
virtual void SetPlatformUserId
(
FPlatformUserId InPlatformUserId |
Changes the platform user that is assigned to this player | Engine/LocalPlayer.h | |
| Create an actor for this player. | Engine/LocalPlayer.h |
Overridden from UPlayer
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void ReceivedPlayerController
(
APlayerController* NewController |
Called when this player has had it's outer Player Controller set for remote net connections | Engine/LocalPlayer.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void ExecMacro
(
const TCHAR* Filename, |
Engine/LocalPlayer.h | ||
virtual void GetViewPoint
(
FMinimalViewInfo& OutViewInfo |
Retrieve the viewpoint of this player. | Engine/LocalPlayer.h |
Overridden from FExec
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual bool Exec_Editor
(
UWorld* InWorld, |
Engine/LocalPlayer.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static void AddReferencedObjects
(
UObject* InThis, |
Engine/LocalPlayer.h | ||
static bool GetPixelBoundingBox
(
const FSceneViewProjectionData& ProjectionData, |
Engine/LocalPlayer.h | ||
static bool GetPixelPoint
(
const FSceneViewProjectionData& ProjectionData, |
Engine/LocalPlayer.h | ||
static TSubsystemClass * GetSubsystem
(
const ULocalPlayer* LocalPlayer |
Get a Subsystem of specified type from the provided LocalPlayer returns nullptr if the Subsystem cannot be found or the LocalPlayer is null | Engine/LocalPlayer.h | |
static TSubsystemClass * GetSubsystemFromController
(
const APlayerController* PC |
Get a subsystem of the specificied type from the provided Player Controller's owning ULocalPlayer. | Engine/LocalPlayer.h |