HPlayer
HPlayer is a high-level wrapper for the local or remote player controller
It extends the core functionality of Controller class, providing utility methods and accessors commonly used in gameplay scripting
Unlike actors or components, HPlayer is not spawned manually, instead it represents an already-existing controller instance, typically associated with a connected player
Each connected player (local or remote) can be accessed and controlled through this class, and a global Players table keeps track of all active instances
Tip
HPlayer is a Controller so it inherits all functions from Controller
Functions#
GetControlledCharacter#
Retrieves the character currently controlled by this player
- returns:
APawn
local character = HPlayer:GetControlledCharacter()
GetCameraLocation#
Returns the camera's world location
- returns:
Vector
local cameraLocation = HPlayer:GetCameraLocation()
GetCameraRotation#
Returns the camera's world rotation
- returns:
FRotator
local cameraRotation = HPlayer:GetCameraRotation()
GetCameraArmLength#
Returns the spring arm length, if any
- returns:
number|nil
local cameraArmLength = HPlayer:GetCameraArmLength()
StartCameraFade#
Starts a fade effect on the camera
- FromAlpha
number - ToAlpha
number - Duration
number - Color
LinearColor - bShouldFadeAudio
boolean - bHoldWhenFinished
boolean
HPlayer:StartCameraFade()
SetManualCameraFade#
Applies a constant fade at a given opacity
- InFadeAmount
number - Color
LinearColor - bInFadeAudio
boolean
HPlayer:SetManualCameraFade()
StopCameraFade#
Stops any active fade effect on the camera
HPlayer:StopCameraFade()
SetCameraLocation#
Moves the spring arm to a new location
- NewLocation
Vector - bSweep
boolean - bTeleport
boolean
HPlayer:SetCameraLocation()
SetCameraRotation#
Rotates the spring arm in world space
- NewRotation
Rotator - bSweep
boolean - bTeleport
boolean
HPlayer:SetCameraRotation()
TranslateCameraTo#
Interpolates the camera's location
- Target
Vector - DeltaTime
number - InterpSpeed
number
HPlayer:TranslateCameraTo()
SetCameraSocketOffset#
Sets the camera's socket offset (end of spring arm)
- Offset
Vector
HPlayer:SetCameraSocketOffset()
SetCameraArmLength#
Sets the arm length for the spring arm
- Length
number - bSkipLerp
boolean
HPlayer:SetCameraArmLength()
AttachCameraTo#
Attaches the camera to another scene component
- InParent
USceneComponent - SocketOffset
Vector - BlendSpeed
number - returns:
boolean
local wasAttached = HPlayer:AttachCameraTo()
ResetCamera#
Resets the camera to its default state
HPlayer:ResetCamera()
RotateCameraTo#
Smoothly rotates the player’s view
- Rotation
Rotator - Time
number - BlendSpeed
number
HPlayer:RotateCameraTo()
SetValue#
Stores a custom value
- key
any - value
any - returns:
boolean
local value = HPlayer:SetValue()
GetValue#
Retrieves a stored custom value
- key
any - returns: any
local value = HPlayer:GetValue()
GetName#
Returns the player's name
- returns:
string
local name = HPlayer:GetName()
GetPing#
Returns the player’s ping
- returns:
number
local ping = HPlayer:GetPing()
IsLocalPlayer#
Checks if this is the local player
- returns:
boolean
local isLocal = HPlayer:IsLocalPlayer()
GiveItemByKey#
Grants an item to the player
- key
string: Registered item key - returns:
ULyraInventoryItemInstance|nil
local giveItem = HPlayer:GiveItemByKey()
RemoveItemByKey#
Removes an item by key
- key
string: Registered item key - returns:
boolean
local removeItem = HPlayer:RemoveItemByKey()
ClearInventory#
Clears the player’s inventory
HPlayer:ClearInventory()
GetAll#
Returns all active players
- returns:
table
local players = HPlayer:GetAll()
GetByIndex#
Gets a player by controller reference
- Controller
APlayerController - returns:
HPlayer
local player = HPlayer:GetByIndex()
GetCount#
Returns the number of tracked players
- returns:
number
local playerCount = HPlayer:GetCount()
JoinVoiceChannel#
Joins particular voice channel id. Only callable by the server/host.
- InChannelId
number
HPlayer:JoinVoiceChannel()
LeaveVoiceChannel#
Leaves particular voice channel id. Only callable by the server/host.
- InChannelId
number
HPlayer:LeaveVoiceChannel()
IsInVoiceChannel#
Checks if player is present in a provided voice channel. Only callable by the server/host.
- InChannelId
number - returns:
boolean
local isInVoiceChannel = HPlayer:IsInVoiceChannel()
MuteInVoiceChannel#
Mutes this player in a particular voice channel. The player can't talk, but is still able to hear others. Only callable by the server/host.
- InChannelId
number
HPlayer:MuteInVoiceChannel()
UnmuteInVoiceChannel#
Unmutes this player in a particular voice channel. Only callable by the server/host.
- InChannelId
number
HPlayer:UnmuteInVoiceChannel()
IsMutedInVoiceChannel#
Checks if player is muted inside a particular voice channel. Only callable by the server/host.
- InChannelId
number - returns:
boolean
local isMuted = HPlayer:IsMutedInVoiceChannel()
MuteForOtherPlayer#
Mutes this player for another player. The other player won't be able to hear this player. Only callable by the server/host.
- InOtherPlayer
APlayerState
HPlayer:MuteForOtherPlayer()
UnmuteForOtherPlayer#
Unmutes this player for another player. Only callable by the server/host.
- InOtherPlayer
APlayerState
HPlayer:UnmuteForOtherPlayer()
IsMutedForOtherPlayer#
Checks if player is muted for another player. Only callable by the server/host.
- InOtherPlayer
APlayerState - returns:
boolean
local isMuted = HPlayer:IsMutedForOtherPlayer()
GetVoiceChannels#
Returns all voice channel ids that the player belongs to. Only callable by the server/host.
- returns:
table
local channelIds = HPlayer:GetVoiceChannels()
IsTalking#
Checks if the player is currently talking. Only callable by the local player.
- returns:
boolean
local isTalking = HPlayer:IsTalking()
GetVoiceAmplitude#
Returns current amplitude of the voice during talking. Only callable by the local player.
- returns:
number
local amplitude = HPlayer:GetVoiceAmplitude()
SetMicNoiseGateThreshold#
Sets threshold at which the voice noise gate cuts off the voice. Only callable by the local player.
- InThreshold
number
HPlayer:SetMicNoiseGateThreshold()
SetMicSilenceDetectionThreshold#
Sets threshold at which the voice system interprets our voice as "silence". When the silence is detected, no information about the audio will be sent. Only callable by the local player.
- InThreshold
number
HPlayer:SetMicSilenceDetectionThreshold()
GetMicNoiseGateThreshold#
Returns threshold at which the voice noise gate cuts off the voice. Only callable by the local player.
- returns:
number
local threshold = HPlayer:GetMicNoiseGateThreshold()
GetMicSilenceDetectionThreshold#
Returns threshold at which the voice system interprets our voice as "silence". When the silence is detected. Only callable by the local player.
- returns:
number
local threshold = HPlayer:GetMicSilenceDetectionThreshold()