Skip to content

PlayerAPI

Accessible via the PlayerAPI Global. This API provides access to all players in the world, including the local player.

NameDescription
FindPlayerByUsername(string username)
(Returns Player)
Returns player entity by username.
FindPlayerByUserId(string userId)
(Returns Player)
Returns player entity by user id.
IsFriendsWith(string userId)
(Returns bool)
Returns whether we’re friends with the userId provided or not.
NameDescription
LocalPlayer : Player
(Returns Player)
Access to Teleport, AddForce, etc.
AllPlayers : List<Player>
(Returns Player)
List of all Player entities (includes the local player).
RemotePlayers : List<Player>
(Returns a list of Player)
List of all Remote Player entities (excludes the local player).
PlayerCount : intTotal connected player count. This includes the local player.

Entity that represents a Player, these Functions and Properties accessible from both local and remote player.

NameDescription
IsLocal : boolIndicates if this is the local player.
IsRemote : boolIndicates if this is a remote player.
Username : stringUsername of the player.
UserID : stringUnique identifier for the player.
Avatar : Avatar
(Returns Avatar)
Get the player’s Avatar Instance.
Spawnables : List<Spawnable>
(Returns List<Spawnable>)
Get the player’s spawned spawnables.

These parameters are set by ChilloutVR to drive the player’s avatar animations. They may not be representative of the actual player’s input in some situations.

NameDescription
Core.MovementXHorizontal movement input value.
Ranges from -1.0 to 1.0.
Core.MovementYVertical movement input value.
Ranges from -1.0 to 1.0.
Core.GestureLeft*Current gesture state of the left hand.
Ranges from -1.0 to 6.0 with 0.0 to 1.0 as fist weight.
Core.GestureLeftIdx*Current gesture without the analog fist weight.
Core.GestureRight*Current gesture state of the right hand.
Ranges from -1.0 to 6.0 with 0.0 to 1.0 as fist weight.
Core.GestureRightIdx*Current gesture without the analog fist weight.
Core.CrouchingIndicates if the player is crouching.
Core.ProneIndicates if the player is prone.
Core.FlyingIndicates if the player is flying.
Core.SittingIndicates if the player is sitting.
Core.SwimmingIndicates if the player is swimming.
Core.GroundedIndicates if the player is on the ground.
Core.ToggleCurrently selected toggle state.
Ranges from 0 to 8.
Core.EmoteTarget emote for the player to play.
Ranges from 0 to 8 and returns to 0 within 0.1s of being set.
Core.CancelEmoteTrigger to cancel the current emote.
True when in a state where an emote should not play.
Core.VisemeIdx**Index value representing the current viseme.
Ranges from 0 to 14.
Core.VisemeLoudnessLoudness level for the current viseme.
Ranges from 0.0 to 1.0.
Core.DistanceToDistance to the local player in meters.
Always 0.0 for the local player. Defaults to -1.0 until first update.

The gesture values are mapped as follows:

  • -1: Open
  • 0: Idle
  • 1: Fist
  • 2: Thumbs Up
  • 3: Handgun
  • 4: Finger Point
  • 5: Peace
  • 6: RockNRoll

The viseme index values are mapped as follows:

  • 0: Sil
  • 1: PP
  • 2: FF
  • 3: TH
  • 4: DD
  • 5: KK
  • 6: CH
  • 7: SS
  • 8: NN
  • 9: RR
  • 10: AA
  • 11: E
  • 12: I
  • 13: O
  • 14: U
NameDescription
GetPosition() : Vector3Current position of the player in world space.
GetRotation() : QuaternionCurrent rotation of the player in world space.
GetForward(): Vector3The forward direction vector of the player.
NameDescription
GetViewPointPosition() : Vector3Position of the viewpoint in the world.
GetViewPointRotation() : QuaternionRotation of the viewpoint in the world.
GetVoicePointPosition() : Vector3Position of the voice point in the world.
GetVoicePointRotation() : QuaternionRotation of the voice point in the world.
NameDescription
GetGravity() : Vector3Current gravity vector affecting the player.
GetGravityDirection() : Vector3Direction of the gravity affecting the player.

Requesting the picture is a bit more complicated as it needs to be acquired in the first place. So it’s not a function that will give the results right away. Instead, it uses a callback lua function, which is basically a normal lua function that gets called whenever the request is finished.

For a complete example, check: Player Profile and Avatar Picture Example

NameDescription
RequestProfileImage(callback OnProfileImage, bool castToTexture) : void
  - #arg1 lua function for the callback
  - #arg2 [Optional] Whether to cast the Texture2D to Texture or not.
Sends a request to fetch the Player’s profile picture as a Texture2D or as a Texture.
NameDescription
OnProfileImage(Texture2D/Texture texture, string userID) : void
  - #arg1 The Texture/Texture2D reference for the player image
  - #arg2 [Optional] The Player’s UserID the image belongs to
Gets called when RequestProfileImage finished and is sending the results

Functions and properties specific to remote players.

NameDescription
IsNameplateActive : boolIndicates whether the nameplate is active or not.
NameDescription
GetNameplatePosition() : Vector3Get the Position of the remote player’s nameplate in the world.

Functions and properties specific to the local player.

NameDescription
IsAuthenticated : boolIndicates whether the Player is authenticated or not.
IsUsingVR : boolIndicates whether the Player is using VR or not.
ImmersionDepth : boolHow deeply the Player is immersed in water.
Ranges from 0 (not immersed) to 1 (fully immersed).
IsImmobilized : boolIndicates whether the Player is immobilized or not.
IsFlying : boolIndicates whether the Player is flying or not or not.
IsFlyingWithNoClip : boolIndicates whether the Player is flying with no clip mode enabled or not.
IsFlightAllowed : boolIndicates whether flying is allowed in the current world or not.
NameDescription
GetHeadingOffset() : floatGet the The angle between the player’s playspace forward and the player’s current forward.
NameDescription
GetPlaySpaceScale() : floatThe ratio of the player’s avatar height to the player’s irl height.
GetPlaySpaceOffset() : Vector3The local offset from the player’s PlaySpace center to their current position.
NameDescription
Respawn() : voidRespawns the player.
SetFlight(bool flightEnable, bool noClipEnabled) : voidSets flight and no clip modes for the player.
SetImmobilized(bool isImmobilized) : voidSets the immobilization status of the player.
AddForce(Vector3 force, ForceMode forceMode) : voidApplies a force to the player.
LaunchCharacter(Vector3 launchVelocity, bool overrideVerticalVelocity, bool overrideLateralVelocity) : voidLaunches the player with a specific velocity.
ResetAllForces() : voidResets all forces currently applied to the player.
PauseGroundConstraint() : voidTemporarily disables ground constraints, allowing the player to freely move off the ground.
GetControllerVelocity() : Vector3 : voidGets the current Player Controller velocity.
SetControllerVelocity(Vector3) : voidSets the current Player Controller velocity.

Note: These functions can only be called by worlds, avatars when WornByMe is true, and props when SpawnedByMe is true.

NameDescription
SetPosition(Vector3 targetPos)Set current position of the player in world space without interpolation, nor grounding the player, nor preserving velocity. For more versatility use the Teleportation methods
SetRotation(Quaternion targetRot)Set current rotation of the player in world space without interpolation, nor grounding the player, nor preserving velocity. For more versatility use the Teleportation methods

Note: These functions can only be called by worlds, avatars when WornByMe is true, and props when SpawnedByMe is true.

NameDescription
TeleportPlayerTo(Vector3 targetPos, bool interpolate, bool updateGround, bool preserveVelocity, Quaternion? rotationDifference)Teleports the player to a specified position with optional rotation difference.
TeleportPlayerTo(Vector3 targetPos, Vector3 targetEulerRot, bool interpolate, bool updateGround, bool preserveVelocity)Teleports the player to a specified position and rotation.
TeleportPlayerTo(Vector3 targetPos, Quaternion targetRot, bool interpolate, bool updateGround, bool preserveVelocity)Teleports the player to a specified position and rotation.
TeleportPlayerTo(Transform targetTransform, bool interpolate, bool updateGround, bool preserveVelocity)Teleports the player to a specified transform, orienting the player with it.

Note: These functions can only be called by worlds, avatars when WornByMe is true, and props when SpawnedByMe is true.

NameDescription
SwitchAvatar(string avatarId)Switches the player’s avatar.
Limited to once every 3 seconds (global timeout).

Note: These functions can only be called by worlds, avatars when WornByMe is true, and props when SpawnedByMe is true.

NameDescription
IKLeftWristToPalmAxis : Vector3Local axis of the left hand bone that points from the wrist towards the palm.
IKLeftPalmToThumbAxis : Vector3Local axis of the left hand bone that points from the palm towards the thumb.
IKRightWristToPalmAxis : Vector3Local axis of the right hand bone that points from the wrist towards the palm.
IKRightPalmToThumbAxis : Vector3Local axis of the right hand bone that points from the palm towards the thumb.
NameDescription
SetBodyControlHeadWeight(weightValue) : void[ 0.0 ; 1.0 ] Sets the Player’s BodySystem Head weight
SetBodyControlPelvisWeight(weightValue) : void[ 0.0 ; 1.0 ] Sets the Player’s BodySystem Pelvis weight
SetBodyControlLeftArmWeight(weightValue) : void[ 0.0 ; 1.0 ] Sets the Player’s BodySystem LeftArm weight
SetBodyControlRightArmWeight(weightValue) : void[ 0.0 ; 1.0 ] Sets the Player’s BodySystem RightArm weight
SetBodyControlLeftLegWeight(weightValue) : void[ 0.0 ; 1.0 ] Sets the Player’s BodySystem LeftLeg weight
SetBodyControlRightLegWeight(weightValue) : void[ 0.0 ; 1.0 ] Sets the Player’s BodySystem RightLeg weight
SetBodyControlLocomotionWeight(weightValue) : void[ 0.0 ; 1.0 ] Sets the Player’s BodySystem Locomotion weight

Note: These functions can only be called by worlds, avatars when WornByMe is true, and props when SpawnedByMe is true.