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

Property

Modifiers

Type

Description

avatar

AvatarComponent

Avatar component attached to the player

avatarData

any

Current avatar data for the player, this is the data used to create the avatar component

avatarReady

Promise<AvatarComponent>

A promise that resolves when the avatar component for the player is created

data

PlayerData

Current data for the player (session id, name, position, rotation etc)

EVENTS

{ userDataChange: string; userChanged: string; }

isAnonymous

readonly

boolean

Returns true if the player is anonymous (not logged in)

isHost

readonly

boolean

Returns true if the player is the host of the game, in multiplayer mode the host is the player who created the game room

name

readonly

string

Returns the player's name

sessionId

readonly

string

Returns the player's session id, in multiplayer this is the id assigned by the server

userId

readonly

string

Returns the player's user id

Methods

Method

Modifiers

Description

getAvatarData()

Returns the default avatar data used to create the avatar component

onUserChange(cb)

onUserDataChange(cb)

setAvatarData(data)

Set the avatar data used to create the avatar component for the player

setOtherAvatarData(data)

Set the others data used to create the avatar component for the player