ULocalPlayer

Each player that is active on the current client/listen server has a LocalPlayer.

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/Engine/LocalPlayer.h

Include

#include "Engine/LocalPlayer.h"

Syntax

class ULocalPlayer : public UPlayer

Remarks

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.

Variables

Name Description

Public variable

TEnumAsByte< en...

 

AspectRatioAxisConstraint

How to constrain perspective viewport FOV

Public variable

uint32: 1

 

bSentSplitJoin

Set when we've sent a split join request

Public variable

FUniqueNetIdRep...

 

CachedUniqueNetId

The FUniqueNetId which this player is associated with.

Public variable

FVector

 

LastViewLocation

The location of the player's view the previous frame.

Public variable

FVector2D

 

Origin

The coordinates for the upper left corner of the primary viewport subregion allocated to this player.

Public variable

TSubclassOf< cl...

 

PendingLevelPlayerControllerClass

The class of PlayerController to spawn for players logging in.

Public variable

FVector2D

 

Size

The size of the primary viewport subregion allocated to this player. 0-1

Protected variable

FReply

 

SlateOperations

FReply used to defer some slate operations.

Public variable

TObjectPtr< cla...

 

ViewportClient

The primary viewport containing this player's view.

Constructors

Name Description

Public function

ULocalPlayer

(
    const FObjectInitializer& ObjectIn...
)

Public function

ULocalPlayer

(
    FVTableHelper& Helper
)

DO NOT USE. This constructor is for internal usage only for hot-reload purposes.

Functions

Name Description

Public function Static

void

 

AddReferencedObjects

(
    UObject* InThis,
    FReferenceCollector& Collector
)

Public function Virtual

FSceneView &...

 

CalcSceneView

(
    FSceneViewFamily* ViewFamily,
    FVector& OutViewLocation,
    FRotator& OutViewRotation,
    FViewport* Viewport,
    FViewElementDrawer* ViewDrawer,
    int32 StereoViewIndex
)

Calculate the view settings for drawing from this view actor

Public function Virtual

bool

 

CalcSceneViewInitOptions

(
    FSceneViewInitOptions& OutInitOpti...,
    FViewport* Viewport,
    FViewElementDrawer* ViewDrawer,
    int32 StereoViewIndex
)

Calculate the view init settings for drawing from this view actor

Public function Virtual

void

 

CleanupViewState

(
    FStringView MidParentRootPath
)

Clear cached view state.

Protected function

void

 

ExecMacro

(
    const TCHAR* Filename,
    FOutputDevice& Ar
)

Public function Const

FUniqueNetId...

 

GetCachedUniqueNetId()

Retrieves this player's unique net ID that was previously cached

Public function Const

int32

 

GetControllerId()

Returns the controller ID for the player.

Public function Const

UGameInstanc...

 

GetGameInstance()

Get the game instance associated with this local player

Public function Virtual Const

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.

Public function Const

int32

 

GetIndexInGameInstance()

Returns the index of this player in the Game instances local players array

Public function Virtual Const

int32

 

GetLocalPlayerIndex()

Returns the logical local player index where 0 is the first LocalPlayer that was created.

Public function Virtual Const

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

Public function Static

bool

 

GetPixelBoundingBox

(
    const FSceneViewProjectionData& Pr...,
    const FBox& ActorBox,
    FVector2D& OutLowerLeft,
    FVector2D& OutUpperRight,
    const FVector2f* OptionalAllot...
)

This function will give you two points in Pixel Space that surround the World Space box.

Public function

bool

 

GetPixelBoundingBox

(
    const FBox& ActorBox,
    FVector2D& OutLowerLeft,
    FVector2D& OutUpperRight,
    const FVector2f* OptionalAllot...
)

This function will give you two points in Pixel Space that surround the World Space box.

Public function

bool

 

GetPixelPoint

(
    const FVector& InPoint,
    FVector2D& OutPoint,
    const FVector2f* OptionalAllot...
)

This function will give you a point in Pixel Space from a World Space position

Public function Static

bool

 

GetPixelPoint

(
    const FSceneViewProjectionData& Pr...,
    const FVector& InPoint,
    FVector2D& OutPoint,
    const FVector2f* OptionalAllot...
)

This function will give you a point in Pixel Space from a World Space position

Public function Const

FPlatformUse...

 

GetPlatformUserId()

Returns the platform user that is assigned to this player

Public function Virtual Const

int32

 

GetPlatformUserIndex()

Converts the platform user id to an index where 0 is the first logged in user.

Public function Virtual Const

FUniqueNetId...

 

GetPreferredUniqueNetId()

Retrieves the preferred unique net id.

Public function Virtual Const

bool

 

GetProjectionData

(
    FViewport* Viewport,
    FSceneViewProjectionData& Projecti...,
    int32 StereoViewIndex
)

Helper function for deriving various bits of data needed for projection

Public function Const

const FReply...

 

GetSlateOperations()

Public function

FReply &

 

GetSlateOperations()

Getter for slate operations.

Public function Virtual

TSharedPtr< ...

 

GetSlateUser()

Get the SlateUser that this LocalPlayer corresponds to

Public function Virtual Const

TSharedPtr< ...

 

GetSlateUser()

Get the SlateUser that this LocalPlayer corresponds to

Public function Static

TSubsystemCl...

 

GetSubsystem

(
    const ULocalPlayer* LocalPlaye...
)

Get a Subsystem of specified type from the provided LocalPlayer returns nullptr if the Subsystem cannot be found or the LocalPlayer is null

Public function Const

TSubsystemCl...

 

GetSubsystem()

Get a Subsystem of specified type

Public function Const

const TArray...

 

GetSubsystemArray()

Get all Subsystem of specified type, this is only necessary for interfaces that can have multiple implementations instanced at a time.

Public function Const

ULocalPlayer...

 

GetSubsystemBase

Get a Subsystem of specified type

Public function Virtual Const

FUniqueNetId...

 

GetUniqueNetIdForPlatformUser()

Retrieves this player's unique net ID from the online subsystem using the platform user Id

Public function Const

FUniqueNetId...

 

GetUniqueNetIdFromCachedControllerId()

This should be deprecated when engine code has been changed to expect FPlatformUserId UE_DEPRECATED(5.x, "Use GetUniqueNetIdForPlatformUser instead")

Protected function Virtual Const

void

 

GetViewPoint

(
    FMinimalViewInfo& OutViewInfo
)

Retrieve the viewpoint of this player.

Public function Virtual Const

UWorld *

 

GetWorld()

Get the world the players actor belongs to

Public function

bool

 

HandleDNCommand

(
    const TCHAR* Cmd,
    FOutputDevice& Ar
)

Exec command handlers

Public function

bool

 

HandleExecCommand

(
    const TCHAR* Cmd,
    FOutputDevice& Ar
)

Public function

bool

 

HandleExitCommand

(
    const TCHAR* Cmd,
    FOutputDevice& Ar
)

Public function

bool

 

HandleListAwakeBodiesCommand

(
    const TCHAR* Cmd,
    FOutputDevice& Ar
)

Public function

bool

 

HandleListMoveBodyCommand

(
    const TCHAR* Cmd,
    FOutputDevice& Ar
)

Public function

bool

 

HandleListPawnComponentsCommand

(
    const TCHAR* Cmd,
    FOutputDevice& Ar
)

Public function

bool

 

HandleListSimBodiesCommand

(
    const TCHAR* Cmd,
    FOutputDevice& Ar
)

Public function

bool

 

HandleListSkelMeshesCommand

(
    const TCHAR* Cmd,
    FOutputDevice& Ar
)

Public function

bool

 

HandleMoveComponentTimesCommand

(
    const TCHAR* Cmd,
    FOutputDevice& Ar
)

Public function

bool

 

HandleToggleDrawEventsCommand

(
    const TCHAR* Cmd,
    FOutputDevice& Ar
)

Public function

bool

 

HandleToggleStreamingVolumesCommand

(
    const TCHAR* Cmd,
    FOutputDevice& Ar
)

Public function Virtual

void

 

InitOnlineSession()

Called to initialize the online delegates

Public function Const

bool

 

IsPrimaryPlayer()

Determines whether this player is the first and primary player on their machine.

Public function Const

FOnControlle...

 

OnControllerIdChanged()

Public function

FOnPlatformU...

 

OnPlatformUserIdChanged()

Public function

FOnPlayerCon...

 

OnPlayerControllerChanged()

Public function Virtual

void

 

PlayerAdded

(
    UGameViewportClient* InViewpor...,
    int32 InControllerID
)

Called at creation time for internal setup

Public function Virtual

void

 

PlayerAdded

(
    UGameViewportClient* InViewpor...,
    FPlatformUserId InUserId
)

Called at creation time for internal setup

Public function Virtual

void

 

PlayerRemoved()

Called when the player is removed from the viewport client

Public function 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

Public function

void

 

SetCachedUniqueNetId

(
    const FUniqueNetIdRepl& NewUniqueN...
)

Sets the players current cached unique net id

Public function 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.

Public function Virtual

void

 

SetPlatformUserId

(
    FPlatformUserId InPlatformUserId
)

Changes the platform user that is assigned to this player

Public function Virtual

bool

 

SpawnPlayActor

(
    const FString& URL,
    FString& OutError,
    UWorld* InWorld
)

Create an actor for this player.

Overridden from UPlayer

Name Description

Public function Virtual

void

 

ReceivedPlayerController

(
    APlayerController* NewControll...
)

Called when this player has had it's outer Player Controller set for remote net connections

Overridden from UObject

Name Description

Public function Virtual

void

 

FinishDestroy()

Called to finish destroying the object.

Overridden from FExec

Name Description

Protected function Virtual

bool

 

Exec_Editor

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

Implementation of Exec that is only called in editor

Classes

Name

Description

Public class

FOnControllerIdChanged

Public class

FOnPlatformUserIdChanged

Event called when this local player has been assigned to a new platform-level user

Public class

FOnPlayerControllerChanged

Event called when this local player has had a new outer PlayerController set

Public struct

FOptionalAllottedSize

Deprecated Functions

Name Description

Public function Static

bool

 

GetPixelBoundingBox

(
    const FSceneViewProjectionData& Pr...,
    const FBox& ActorBox,
    FVector2D& OutLowerLeft,
    FVector2D& OutUpperRight,
    FOptionalAllottedSize OptionalAllot...
)

Please use const FVector2f* directly

Public function

bool

 

GetPixelBoundingBox

(
    const FBox& ActorBox,
    FVector2D& OutLowerLeft,
    FVector2D& OutUpperRight,
    FOptionalAllottedSize OptionalAllot...
)

Please use const FVector2f* directly

Public function

bool

 

GetPixelPoint

(
    const FVector& InPoint,
    FVector2D& OutPoint,
    FOptionalAllottedSize OptionalAllot...
)

Please use const FVector2f* directly

Public function Static

bool

 

GetPixelPoint

(
    const FSceneViewProjectionData& Pr...,
    const FVector& InPoint,
    FVector2D& OutPoint,
    FOptionalAllottedSize OptionalAllot...
)

Please use const FVector2f* directly

Public function Const

bool

 

IsCachedUniqueNetIdPairedWithControllerId()

Platform User Id now has priority over ControllerId, these are not expected to be the same

Public function

void

 

SetCachedUniqueNetId

(
    TYPE_OF_NULLPTR
)

Use SetCachedUniqueNetId with FUniqueNetIdRepl

Public function

void

 

SetCachedUniqueNetId

(
    FUniqueNetIdPtr NewUniqueNetId
)

Use SetCachedUniqueNetId with FUniqueNetIdRepl

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Cancel