Skip to content
FMFallout Multiplayer Scripting APIScripting guides and API
Global objectClient APIGenerated

Camera

const Camera: object

Defined in: client/api.d.ts:637

The camera the world renders through, as of the last frame, whichever state holds it: first or third person, the fly camera, a scripted one.

forceFirstPerson(): boolean

Puts the player’s camera in first person, as Game.ForceFirstPerson does. The game only does it while the camera follows the player.

boolean

False before the camera exists.

forceThirdPerson(): boolean

Puts the player’s camera in third person, as Game.ForceThirdPerson does. The game refuses from some states, such as furniture, and waits for an open menu to close.

boolean

False before the camera exists.

getCrosshairTarget(): { distance: number; entity: number | null; ref: number; } | null

What lies under the crosshair, as the game picks it for the activation prompt, the activate button and VATS: the reference, the network ID of the player or NPC it stands for when it is one, and how far it is from the player in game units.

{ distance: number; entity: number | null; ref: number; } | null

Null with nothing under the crosshair. It is the activation pick: an actor is under it only when the game offers to activate it, so another player’s body never is; Camera.raycast strikes it.

getFov(): { horizontal: number; vertical: number; } | null

The field of view the world renders with, in degrees, across and up the screen. Null before the world is built.

{ horizontal: number; vertical: number; } | null

getPosition(): { x: number; y: number; z: number; } | null

Where the camera is, in world units; null before the world is built.

{ x: number; y: number; z: number; } | null

getRotation(): { pitch: number; yaw: number; } | null

Where the camera looks: pitch in radians, positive down; yaw in radians in [0, 2pi), 0 facing +Y, clockwise. Null before the world is built.

{ pitch: number; yaw: number; } | null

getScreenSize(): object

The game’s back buffer, in pixels: the space worldToScreen answers in.

object

height: number

width: number

getTarget(): number | null

The network ID of the body the camera was told to follow; null while it follows the player’s own.

number | null

isFirstPerson(): boolean

Whether the player’s camera is in its first-person state.

boolean

False in third person and in every other state: the fly camera, furniture, a scripted camera.

raycast(distance?, options?): { entity: number | null; fraction: number; hit: boolean; normal: Vector3; position: Vector3; ref: number | null; } | null

What the player is aiming at: World.raycast from the camera through the middle of the screen, where the crosshair sits, in first or third person. Unlike getCrosshairTarget it strikes anything solid, other players’ bodies included.

number

How far to look, in game units; 10000 when left out.

As World.raycast’s: the actor whose body the ray passes over, the local player by default.

number | string | null

{ entity: number | null; fraction: number; hit: boolean; normal: Vector3; position: Vector3; ref: number | null; } | null

As World.raycast’s; null before the world is built or the player is in a cell.

setFov(degrees): boolean

Sets the field of view the world renders with, as FiveM’s SetCamFov and the console’s fov do: a zoom for a cutscene, a fish-eye for a drunk effect. It holds through camera changes until set again; the game’s own comes back with null or when the session ends. The player’s own settings are not touched.

number | null

The horizontal field of view, 10 to 160 degrees; null for the game’s own.

boolean

False before the world is built.

setTarget(entityId): boolean

Makes the camera follow another body in third person, as Game.SetCameraTarget does: what a spectator mode is built on. The player’s own body stays where it is and still takes its input; the camera comes back by itself when the body followed leaves this game.

number | null

The network ID of a player or an NPC, as the server knows it (player.id); null for the player’s own body.

boolean

False when no such player or NPC has a body loaded here.

setView(view): boolean

Takes the camera from the player and puts it where the script says, as FiveM’s CreateCam, SetCamCoord, PointCamAtCoord and RenderScriptCams do: a cutscene shot, a security camera, an intro flight. The player’s controls move neither the camera nor their body while it is up: their movement, looking, jumping and fighting are held off, and their body keeps its heading. Called again it moves: a script tweens it by calling every tick. It is given back with null, when the resource that set it stops, or when the session ends.

{ lookAt?: Vector3; position: Vector3; rotation?: { pitch: number; yaw: number; }; } | null

Where the camera stands, and where it looks: a rotation in radians (pitch positive down, yaw 0 facing +Y, clockwise) or a point to face. Null gives the player their camera back.

boolean

False when there is no player in a cell, or the console’s fly camera holds the camera.

worldToScreen(x, y, z): { onScreen: boolean; x: number; y: number; } | null

Projects a world point through last frame’s camera into back-buffer pixels, origin top left (see getScreenSize; scale by the web view’s size over it). onScreen is false for a point in front of the camera but outside the view. Null for a point behind the camera, or before the world is built.

number

World units.

number

World units.

number

World units.

{ onScreen: boolean; x: number; y: number; } | null