Skip to content

camera.setFixed

Puts a player’s camera at position, looking at lookAt. The player keeps playing: they can still move and be hurt. The game loads the world around the camera as well as around the player, so a camera far from the player shows that place in full; after a long move it can take a moment to fill in. playerCameraChangeRequest is asked first. Use camera.reset to give them their own camera back.

camera.setFixed(viewer: PlayerTarget, position: Vector3, lookAt: Vector3, interior?: number, options?: ViewListenOptions): Promise<ActionResult>
Name Type Description
viewer PlayerTarget The player whose camera it is.
position Vector3 Where the camera is.
lookAt Vector3 The point it looks at.
interior number Optional. The interior the camera is in: 0 outside, 1-18 an interior’s.
options ViewListenOptions Optional. listenAtView: true: the viewer hears nearby chat at the camera instead of where their character is.

A promise of an ActionResult: applied once the player’s camera is there, rejected with a code, or timeout after 21 seconds without an answer.

Code Meaning
view-denied playerCameraChangeRequest refused it.
invalid-camera-position position or lookAt is not a place on the map.
invalid-value options.listenAtView is not a boolean.
resource-unavailable The player’s game cannot load the world around both the camera and the player.
spectating-active The player is spectating: players.stopSpectating first.
player-not-found No such player, or they left meanwhile.
gamemodes/my-mode.ts
import { camera, commands } from "nativemp";
commands.register("skyline", async (player) => {
await camera.setFixed(player, [1544, -1675, 65], [1544, -1675, 15]);
});