<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [server](./server.md) &gt; [Player](./server.player.md)

## Player class

A connected player in the game.

When to use: interacting with a connected player's state, UI, and world membership. Do NOT use for: constructing players or representing offline users.

**Signature:**

```typescript
export default class Player extends EventRouter implements protocol.Serializable 
```
**Extends:** [EventRouter](./server.eventrouter.md)

**Implements:** protocol.Serializable

## Remarks

Players are created automatically on connection by `PlayerManager`<!-- -->.

<h2>Events</h2>

This class is an EventRouter, and instances of it emit events with payloads listed under `PlayerEventPayloads`<!-- -->.

\*\*Category:\*\* Players

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

<table><thead><tr><th>

Property


</th><th>

Modifiers


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[camera](./server.player.camera.md)


</td><td>

`readonly`


</td><td>

[PlayerCamera](./server.playercamera.md)


</td><td>

The camera for the player.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[cosmetics](./server.player.cosmetics.md)


</td><td>

`readonly`


</td><td>

Promise&lt;[PlayerCosmetics](./server.playercosmetics.md) \| void&gt;


</td><td>

The cosmetics for the player.


</td></tr>
<tr><td>

[id](./server.player.id.md)


</td><td>

`readonly`


</td><td>

string


</td><td>

The unique HYTOPIA UUID for the player.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[input](./server.player.input.md)


</td><td>

`readonly`


</td><td>

[PlayerInput](./server.playerinput.md)


</td><td>

The current `PlayerInput` of the player.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[isInteractEnabled](./server.player.isinteractenabled.md)


</td><td>

`readonly`


</td><td>

boolean


</td><td>

Whether player click/tap input triggers interactions.


</td></tr>
<tr><td>

[maxInteractDistance](./server.player.maxinteractdistance.md)


</td><td>

`readonly`


</td><td>

number


</td><td>

The maximum distance a player can interact with entities or blocks.


</td></tr>
<tr><td>

[profilePictureUrl](./server.player.profilepictureurl.md)


</td><td>

`readonly`


</td><td>

string \| undefined


</td><td>

The profile picture URL for the player.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[ui](./server.player.ui.md)


</td><td>

`readonly`


</td><td>

[PlayerUI](./server.playerui.md)


</td><td>

The UI for the player.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[username](./server.player.username.md)


</td><td>

`readonly`


</td><td>

string


</td><td>

The unique HYTOPIA username for the player.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[world](./server.player.world.md)


</td><td>

`readonly`


</td><td>

[World](./server.world.md) \| undefined


</td><td>

The current `World` the player is in, or undefined if not yet joined.

\*\*Category:\*\* Players


</td></tr>
</tbody></table>

## Methods

<table><thead><tr><th>

Method


</th><th>

Modifiers


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[disconnect()](./server.player.disconnect.md)


</td><td>


</td><td>

Disconnects the player from the game server.

Use for: kicking a player or enforcing a logout. Do NOT use for: switching worlds; use `Player.joinWorld` instead.

\*\*Side effects:\*\* Emits `PlayerEvent.LEFT_WORLD` if the player is in a world and closes the connection.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[getPersistedData()](./server.player.getpersisteddata.md)


</td><td>


</td><td>

Gets the persisted data for the player, if available.

Use for: reading saved progress after the player connects.


</td></tr>
<tr><td>

[joinWorld(world)](./server.player.joinworld.md)


</td><td>


</td><td>

Assigns the player to a world.

Use for: initial placement or moving a player between worlds. Do NOT use for: respawning or teleporting within the same world.


</td></tr>
<tr><td>

[resetInputs()](./server.player.resetinputs.md)


</td><td>


</td><td>

Resets all cached input keys for the player.

Use for: clearing stuck input states (e.g., after disconnect or pause).

\*\*Side effects:\*\* Clears the current `PlayerInput` state.

\*\*Category:\*\* Players


</td></tr>
<tr><td>

[scheduleNotification(type, scheduledFor)](./server.player.schedulenotification.md)


</td><td>


</td><td>

Schedules a notification for the player at a future time.

Use for: re-engagement or timed reminders. Do NOT use for: immediate in-game messaging; use chat or UI instead.


</td></tr>
<tr><td>

[setInteractEnabled(enabled)](./server.player.setinteractenabled.md)


</td><td>


</td><td>

Enables or disables interaction clicks/taps for this player.

Use for: cutscenes, menus, or temporary input blocking.


</td></tr>
<tr><td>

[setMaxInteractDistance(distance)](./server.player.setmaxinteractdistance.md)


</td><td>


</td><td>

Sets the maximum distance a player can interact with entities or blocks.


</td></tr>
<tr><td>

[setPersistedData(data)](./server.player.setpersisteddata.md)


</td><td>


</td><td>

Merges data into the player's persisted data cache.

Use for: saving progress, inventory, or other player-specific state. Do NOT use for: large binary data or per-tick updates.


</td></tr>
<tr><td>

[unscheduleNotification(notificationId)](./server.player.unschedulenotification.md)


</td><td>


</td><td>

Unschedules a scheduled notification for the player.


</td></tr>
</tbody></table>
