Skip to content

Camera

What a player sees. Each player’s device has its own, at workspace.currentCamera.

  • Inherits: Instance
  • Creatable: No. Each player’s device creates its own.
  • Replication: Local to each player’s device: it’s created there, and the server never has one.

When the game starts on a player’s device, it creates a Camera named Camera in the Workspace and makes it workspace.currentCamera. It never exists on the server. In 2D games it starts with a distance of 14.

In 'follow' mode the camera follows subject (the player’s character by default): in 3D it orbits behind it and the player turns it with the mouse; in 2D it tracks it from the side. In 'fixed' and 'scriptable' mode, which currently behave the same, it stays where position and lookAt put it.

Type: CameraType · Default: 'follow' · Access: read/write

How the camera moves.

Type: Vector3 · Default: new Vector3(0, 20, 30) · Access: read/write

Where the camera is. In 'follow' mode the player updates it every frame, so you can read where the camera is; in the other modes, set it. In 2D the view is centered on position.x and position.y.

Type: Vector3 · Default: new Vector3(0, 0, 0) · Access: read/write

The point the camera looks at. Updated every frame in 'follow' mode; set it in the other modes. 2D cameras always face the X/Y plane, so 2D games don’t use it.

Type: number · Default: 70 · Range: 10 to 120 (clamped) · Access: read/write

Degrees (3D).

Type: number · Default: 18 · Range: 2 to 200 (clamped) · Access: read/write

Follow distance in 3D; half the visible height in 2D.

With default controls on, the mouse wheel zooms it between 4 and 80 studs in 3D, or 4 and 60 in 2D.

Type: Instance | null · Default: null · Access: read/write

What to follow (defaults to your character).

A Character or a BasePart; with anything else the camera stays where it is.

Inherited from Instance: name, archivable, id, className, parent, destroyed

Inherited from Instance: getPropertyChangedSignal, setAttribute, getAttribute, getAttributes, getAttributeChangedSignal, getChildren, getDescendants, findFirstChild, findFirstChildOfClass, findFirstChildWhichIsA, findFirstAncestor, findFirstAncestorWhichIsA, waitForChild, isA, isDescendantOf, isAncestorOf, getFullName, clearAllChildren, destroy, clone, toString

Inherited from Instance: changed, childAdded, childRemoved, descendantAdded, descendantRemoving, ancestryChanged, destroying, attributeChanged

import { Vector3, workspace } from '@rally/sdk';
// LocalScript: look at the arena from a corner.
const camera = workspace.currentCamera;
if (camera) {
camera.cameraType = 'scriptable';
camera.position = new Vector3(60, 45, 60);
camera.lookAt = new Vector3(0, 0, 0);
camera.fieldOfView = 50;
}