Playerwrapper

PlayerWrapper class

Represents a player entity in the game.

A PlayerWrapper instance is always created for the main player of the game; In mulitplayer mode, a PlayerWrapper instanceRor remote players in mulitplayer mode.

By default an avatar component is created for each player. You can customise the avatar used by the game using the current snippet in the onPreload method of the script

Signature:

export declare class PlayerWrapper 

Remarks

The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the PlayerWrapper class.

Properties

PropertyModifiersTypeDescription
avatarAvatarComponentAvatar component attached to the player
avatarDataanyCurrent avatar data for the player, this is the data used to create the avatar component
avatarReadyPromise<AvatarComponent>A promise that resolves when the avatar component for the player is created
dataPlayerDataCurrent data for the player (session id, name, position, rotation etc)
isAnonymousreadonlybooleanReturns true if the player is anonymous (not logged in)
isHostreadonlybooleanReturns true if the player is the host of the game, in multiplayer mode the host is the player who created the game room
namereadonlystringReturns the player's name
sessionIdreadonlystringReturns the player's session id, in multiplayer this is the id assigned by the server
userIdreadonlystringReturns the player's user id

Methods

MethodModifiersDescription
getAvatarData()Returns the default avatar data used to create the avatar component
setAvatarData(data)Set the avatar data used to create the avatar component for the player