players.freecam
Has viewer fly a free camera: the mouse looks, WASD flies along the view, Space and Ctrl rise and sink, and holding
Shift (Cross or A on a controller) flies at fastSpeed. Their character is hidden at the camera, so the world loads
around it, and it can neither act nor be hurt, as while spectating.
The freecam ends with players.stopFreecam, which also picks where the player
lands, and playerViewEnded says so with mode: "freecam".
Signature
Section titled “Signature”players.freecam(viewer: PlayerTarget, options?: FreecamOptions): Promise<ActionResult>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
viewer |
PlayerTarget |
The player who flies. |
options |
FreecamOptions |
Optional. How fast they fly; 12 m/s, and four times that with Shift, by default. listenAtView: true: they hear nearby chat at the camera instead of where they started flying. |
Returns
Section titled “Returns”A promise of an ActionResult: applied once they fly, rejected with a code, or
timeout after 21 seconds without an answer.
| Code | Meaning |
|---|---|
invalid-freecam-speed |
A speed is not a number from 0.5 to 500. |
invalid-value |
options.listenAtView is not a boolean. |
spectating-active |
The viewer is spectating; stop that first. |
freecam-active |
The viewer is already flying; use players.setFreecamSpeed to change speed. |
view-change-pending |
The viewer is still coming back from their last view; try again in a moment. |
view-decision-pending |
Your gamemode is still deciding on a view change for this player; try again once it has answered. |
resource-unavailable |
The viewer’s game has no room to load more of the world right now. |
player-not-found |
No such player, or they left meanwhile. |
Example
Section titled “Example”import { commands, players } from "nativemp";
commands.register("fly", async (player) => { await players.freecam(player, { speed: 20 });});Related
Section titled “Related”players.stopFreecam,players.setFreecamSpeedFreecamOptionsplayerViewEndedplayers.spectate: watch a player or vehicle instead