UNPKG

hytopia

Version:

The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.

289 lines (128 loc) 3.62 kB
<!-- 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 player in the game. **Signature:** ```typescript export default class Player extends EventRouter implements protocol.Serializable ``` **Extends:** [EventRouter](./server.eventrouter.md) **Implements:** protocol.Serializable ## Remarks Players are automatically created when they connect and authenticate with the game server. This is all handled internally. <h2>Events</h2> This class is an EventRouter, and instances of it emit events with payloads listed under [PlayerEventPayloads](./server.playereventpayloads.md) 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. </td></tr> <tr><td> [id](./server.player.id.md) </td><td> `readonly` </td><td> string </td><td> The unique HYTOPIA UUID for the player. </td></tr> <tr><td> [input](./server.player.input.md) </td><td> `readonly` </td><td> [PlayerInput](./server.playerinput.md) </td><td> The current [PlayerInput](./server.playerinput.md) of the player. </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. </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. </td></tr> <tr><td> [username](./server.player.username.md) </td><td> `readonly` </td><td> string </td><td> The unique HYTOPIA username for the player. </td></tr> <tr><td> [world](./server.player.world.md) </td><td> `readonly` </td><td> [World](./server.world.md) \| undefined </td><td> The current [World](./server.world.md) the player is in. </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. </td></tr> <tr><td> [getPersistedData()](./server.player.getpersisteddata.md) </td><td> </td><td> Get the persisted data for the player. </td></tr> <tr><td> [joinWorld(world)](./server.player.joinworld.md) </td><td> </td><td> Joins a player to a world. </td></tr> <tr><td> [resetInputs()](./server.player.resetinputs.md) </td><td> </td><td> Resets all inputs keys </td></tr> <tr><td> [setPersistedData(data)](./server.player.setpersisteddata.md) </td><td> </td><td> Set the persisted data for the player. This data can later be retrieved using [Player.getPersistedData()](./server.player.getpersisteddata.md)<!-- -->, even if a player disconnects and rejoin a game in the future, or joins a different HYTOPIA managed lobby of your game. </td></tr> </tbody></table>