Skip to content

Latest commit

 

History

History
288 lines (128 loc) · 3.54 KB

File metadata and controls

288 lines (128 loc) · 3.54 KB

Home > server > Player

Player class

A player in the game.

Signature:

export default class Player extends EventRouter implements protocol.Serializable 

Extends: EventRouter

Implements: protocol.Serializable

Remarks

Players are automatically created when they connect and authenticate with the game server. This is all handled internally.

Events

This class is an EventRouter, and instances of it emit events with payloads listed under PlayerEventPayloads

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

Properties

Property

Modifiers

Type

Description

camera

readonly

PlayerCamera

The camera for the player.

id

readonly

string

The unique HYTOPIA UUID for the player.

input

readonly

PlayerInput

The current PlayerInput of the player.

profilePictureUrl

readonly

string | undefined

The profile picture URL for the player.

ui

readonly

PlayerUI

The UI for the player.

username

readonly

string

The unique HYTOPIA username for the player.

world

readonly

World | undefined

The current World the player is in.

Methods

Method

Modifiers

Description

disconnect()

Disconnects the player from the game server.

getPersistedData()

Get the persisted data for the player.

joinWorld(world)

Joins a player to a world.

resetInputs()

Resets all inputs keys

setPersistedData(data)

Set the persisted data for the player. This data can later be retrieved using Player.getPersistedData(), even if a player disconnects and rejoin a game in the future, or joins a different HYTOPIA managed lobby of your game.