# Camera

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [PVInstance](https://rapi.sleaze.dev/classes/PVInstance.md), [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Subclasses: [ViewportCamera](https://rapi.sleaze.dev/classes/ViewportCamera.md)
- Tags: Not replicated
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/Camera/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/Camera

A class which defines a view of the 3D world.

## Properties

### CameraSubject

```luau
Camera.CameraSubject: Instance
```

- Tags: Capabilities: Basic

The [`Humanoid`](https://rapi.sleaze.dev/classes/Humanoid.md) or [`BasePart`](https://rapi.sleaze.dev/classes/BasePart.md) that is the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) subject.

### CameraType

```luau
Camera.CameraType: Enum.CameraType = Enum.CameraType.Fixed
```

- Tags: Capabilities: Basic

Specifies the [`CameraType`](https://rapi.sleaze.dev/classes/Camera.md) to be read by the camera scripts.

### DiagonalFieldOfView

```luau
Camera.DiagonalFieldOfView: number = 88.8765335
```

- Tags: Not replicated, Capabilities: Basic

Sets the angle of the camera's diagonal field of view.

### FieldOfView

```luau
Camera.FieldOfView: number = 70
```

- Tags: Capabilities: Basic

Sets the angle of the camera's vertical field of view.

### FieldOfViewMode

```luau
Camera.FieldOfViewMode: Enum.FieldOfViewMode = Enum.FieldOfViewMode.Vertical
```

- Tags: Capabilities: Basic

Determines the FOV value of the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) that's invariant under viewport size changes.

### MaxAxisFieldOfView

```luau
Camera.MaxAxisFieldOfView: number = 70
```

- Tags: Not replicated, Capabilities: Basic

Sets the angle of the camera's field of view along the longest viewport axis.

### OrthographicMode

```luau
Camera.OrthographicMode: Enum.OrthographicMode = Enum.OrthographicMode.Vertical
```

- Tags: Capabilities: Basic

### OrthographicSize

```luau
Camera.OrthographicSize: number = 300
```

- Tags: Capabilities: Basic

### ProjectionType

```luau
Camera.ProjectionType: Enum.ProjectionType = Enum.ProjectionType.Perspective
```

- Tags: Capabilities: Basic

### ViewStretch

```luau
Camera.ViewStretch: number = 1
```

- Tags: Capabilities: Basic

### CFrame

```luau
Camera.CFrame: CFrame = CFrame.new(0, 20, 20, 1, 0, -0, -0, 0.707106829, 0.707106829, 0, -0.707106829, 0.707106829)
```

- Tags: Capabilities: Basic, Simulation access

The [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) of the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md), defining its position and orientation in the 3D world.

### Focus

```luau
Camera.Focus: CFrame = CFrame.new(0, 0, -5, 1, 0, 0, 0, 1, 0, 0, 0, 1)
```

- Tags: Capabilities: Basic, Simulation access

Sets the area in 3D space that is prioritized by Roblox's graphical systems.

### HeadLocked

```luau
Camera.HeadLocked: boolean = true
```

- Tags: Capabilities: Basic

Toggles whether the camera will automatically track the head motion of a player using a VR device.

### HeadScale

```luau
Camera.HeadScale: number = 1
```

- Tags: Capabilities: Basic

Sets the scale of the user's perspective of the world when using VR.

### NearPlaneZ

```luau
Camera.NearPlaneZ: number = -0.5
```

- Tags: Read only, Capabilities: Basic, Save only

Describes the negative **Z** offset, in studs, of the camera's near clipping plane.

### ViewportSize

```luau
Camera.ViewportSize: Vector2 = Vector2.one
```

- Tags: Read only, Capabilities: Basic, Save only

The dimensions of the device safe area on a Roblox client.

### VRTiltAndRollEnabled

```luau
Camera.VRTiltAndRollEnabled: boolean = false
```

- Tags: Capabilities: Basic

Toggles whether to apply tilt and roll from the [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) property while the player is using a VR device.

### CoordinateFrame

```luau
Camera.CoordinateFrame: CFrame = CFrame.new(0, 20, 20, 1, 0, -0, -0, 0.707106829, 0.707106829, 0, -0.707106829, 0.707106829)
```

- Tags: Deprecated, Hidden, Not replicated, Capabilities: Basic, Load only, Simulation access
- Use instead: [`Camera.CFrame`](https://rapi.sleaze.dev/classes/Camera.md)

**Deprecated:** This item has been superseded by [`Camera.CFrame`](https://rapi.sleaze.dev/classes/Camera.md) which should be used in all new work.

### focus

```luau
Camera.focus: CFrame = CFrame.new(0, 0, -5, 1, 0, 0, 0, 1, 0, 0, 0, 1)
```

- Tags: Deprecated, Not replicated, Capabilities: Basic, Load only
- Use instead: [`Camera.Focus`](https://rapi.sleaze.dev/classes/Camera.md)

**Deprecated:** This property is a deprecated variant of [`Focus`](https://rapi.sleaze.dev/classes/Camera.md) which should be used instead.

## Methods

### GetPartsObscuringTarget

```luau
Camera:GetPartsObscuringTarget(castPoints: { any }, ignoreList: { Instance }): { Instance }
```

- Tags: Capabilities: Basic

Returns an array of `BaseParts` that are obscuring the lines of sight between the camera's [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) and the cast points.

Parameters:

- `castPoints`: An array of [`Vector3`](https://rapi.sleaze.dev/index/types/Vector3.md) positions of cast points.
- `ignoreList`: An array of [`Instances`](https://rapi.sleaze.dev/index/types/Instances.md) that should be ignored, along with their descendants.

Returns: An array of `BaseParts` that obscure the lines of sight between the camera's [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) and the `castPoints`.

### GetRenderCFrame

```luau
Camera:GetRenderCFrame(): CFrame
```

- Tags: Capabilities: Basic

Returns the actual [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md)where the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) is being rendered, accounting for any roll applied and the impact of VR devices.

Returns: The [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) is being rendered at.

### GetRoll

```luau
Camera:GetRoll(): number
```

- Tags: Capabilities: Basic

Returns in radians the current roll, or rotation around the camera's Z-axis, applied to the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) using [`SetRoll()`](https://rapi.sleaze.dev/classes/Camera.md).

Returns: The current roll applied by [`SetRoll()`](https://rapi.sleaze.dev/classes/Camera.md), in radians.

### ScreenPointToRay

```luau
Camera:ScreenPointToRay(x: number, y: number, depth: number? = 0): Ray
```

- Tags: Thread safe, Capabilities: Basic

Creates a unit [`Ray`](https://rapi.sleaze.dev/index/types/Ray.md) from a position on the screen (in pixels), at a set depth from the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) orientated in the camera's direction. Accounts for the GUI inset.

Parameters:

- `x`: The position on the **X** axis, in pixels, of the screen point at which to originate the [`Ray`](https://rapi.sleaze.dev/index/types/Ray.md). This position accounts for the GUI inset.
- `y`: The position on the **Y** axis, in pixels, of the screen point at which to originate the [`Ray`](https://rapi.sleaze.dev/index/types/Ray.md). This position accounts for the GUI inset.
- `depth`: The depth from the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md), in studs, from which to offset the origin of the [`Ray`](https://rapi.sleaze.dev/index/types/Ray.md).

Returns: A unit [`Ray`](https://rapi.sleaze.dev/index/types/Ray.md), originating from the equivalent [`Vector3`](https://rapi.sleaze.dev/index/types/Vector3.md) world position of the given screen coordinates at the given depth away from the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md). This ray is orientated in the direction of the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md).

### SetImageServerView

```luau
Camera:SetImageServerView(modelCoord: CFrame)
```

- Tags: Roblox script security, Capabilities: Basic

### SetRoll

```luau
Camera:SetRoll(rollAngle: number)
```

- Tags: Capabilities: Basic

Sets the current rotation applied around the camera's Z-axis.

Parameters:

- `rollAngle`: The roll angle, in radians, to be applied to the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md).

### ViewportPointToRay

```luau
Camera:ViewportPointToRay(x: number, y: number, depth: number? = 0): Ray
```

- Tags: Thread safe, Capabilities: Basic

Creates a unit [`Ray`](https://rapi.sleaze.dev/index/types/Ray.md) from a position on the viewport (in pixels), at a given depth from the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md), orientated in the camera's direction. Does not account for the `CoreUISafeInsets` inset.

Parameters:

- `x`: The position on the **X** axis, in pixels, of the viewport point at which to originate the [`Ray`](https://rapi.sleaze.dev/index/types/Ray.md), in device safe area coordinates.
- `y`: The position on the **Y** axis, in pixels, of the viewport point at which to originate the [`Ray`](https://rapi.sleaze.dev/index/types/Ray.md), in device safe area coordinates.
- `depth`: The depth from the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md), in studs, from which to offset the origin of the [`Ray`](https://rapi.sleaze.dev/index/types/Ray.md).

Returns: A unit [`Ray`](https://rapi.sleaze.dev/index/types/Ray.md), originating from the equivalent [`Vector3`](https://rapi.sleaze.dev/index/types/Vector3.md) world position of the given viewport coordinates at the given depth away from the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md). This ray is orientated in the direction of the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md).

### WorldToScreenPoint

```luau
Camera:WorldToScreenPoint(worldPoint: Vector3): ...any
```

- Tags: Thread safe, Capabilities: Basic

Returns the screen location and depth of a [`Vector3`](https://rapi.sleaze.dev/index/types/Vector3.md) `worldPoint` and whether this point is within the bounds of the screen. Accounts for the GUI inset.

Parameters:

- `worldPoint`: The [`Vector3`](https://rapi.sleaze.dev/index/types/Vector3.md) world position.

Returns: A tuple containing, in order:

- A [`Vector3`](https://rapi.sleaze.dev/index/types/Vector3.md) whose **X** and **Y** components represent the offset of the `worldPoint` from the top left corner of the screen, in pixels. The [`Vector3`](https://rapi.sleaze.dev/index/types/Vector3.md)**Z** component represents the depth of the `worldPoint` from the screen (in studs).
- A boolean indicating if the `worldPoint` is within the bounds of the screen.

### WorldToViewportPoint

```luau
Camera:WorldToViewportPoint(worldPoint: Vector3): ...any
```

- Tags: Thread safe, Capabilities: Basic

Returns the screen location and depth of a [`Vector3`](https://rapi.sleaze.dev/index/types/Vector3.md) `worldPoint` and whether this point is within the bounds of the screen. Does not account for the GUI inset.

Parameters:

- `worldPoint`: The [`Vector3`](https://rapi.sleaze.dev/index/types/Vector3.md) world position.

Returns: A tuple containing, in order:

- A [`Vector3`](https://rapi.sleaze.dev/index/types/Vector3.md) whose **X** and **Y** components represent the offset of the `worldPoint` from the top left corner of the viewport, in pixels for [`Workspace.CurrentCamera`](https://rapi.sleaze.dev/classes/Workspace.md). For cameras inside a [`ViewportFrame`](https://rapi.sleaze.dev/classes/ViewportFrame.md), the values are normalized to [0, 1]. The [`Vector3`](https://rapi.sleaze.dev/index/types/Vector3.md)**Z** component represents the depth of the `worldPoint` from the screen (in studs).
- A boolean indicating if the `worldPoint` is within the bounds of the screen.

### Zoom

```luau
Camera:Zoom(distance: number): boolean
```

- Tags: Roblox script security, Capabilities: Basic

### ZoomToExtents

```luau
Camera:ZoomToExtents(boundingBoxCFrame: CFrame, boundingBoxSize: Vector3)
```

- Tags: Capabilities: Basic

Adjusts the [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) so that the specified bounding box is fully visible within the camera's viewport.

Parameters:

- `boundingBoxCFrame`: The [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) representing the center and orientation of the bounding box to fit into the viewport.
- `boundingBoxSize`: The [`Vector3`](https://rapi.sleaze.dev/index/types/Vector3.md) size of the bounding box to fit into the viewport.

### GetLargestCutoffDistance

```luau
Camera:GetLargestCutoffDistance(ignoreList: { Instance }): number
```

- Tags: Deprecated, Capabilities: Basic

**Deprecated:** This method is deprecated. Do not use it for new work.

Returns how much the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) needs to be pushed towards its [`Focus`](https://rapi.sleaze.dev/classes/Camera.md) in order to make sure there is no obstructions between the [`Focus`](https://rapi.sleaze.dev/classes/Camera.md) and [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md).

Parameters:

- `ignoreList`: An array of [`Instances`](https://rapi.sleaze.dev/index/types/Instances.md) to ignore. Descendants of these instances will also be ignored.

Returns: The distance, in studs, that the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) needs to be pushed towards its [`Focus`](https://rapi.sleaze.dev/classes/Camera.md) to ensure there are no obstructions between the [`Focus`](https://rapi.sleaze.dev/classes/Camera.md) and [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) of the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md).

### GetPanSpeed

```luau
Camera:GetPanSpeed(): number
```

- Tags: Deprecated, Capabilities: Basic

**Deprecated:** This method has been deprecated and no longer works. It should not be used in new work.

Returns the current 'pan' speed of the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md).

Returns: The speed at which the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) is rotating around its [`Focus`](https://rapi.sleaze.dev/classes/Camera.md) on the **Y** axis.

### GetTiltSpeed

```luau
Camera:GetTiltSpeed(): number
```

- Tags: Deprecated, Capabilities: Basic

**Deprecated:** This method has been deprecated and no longer works.

Returns the current tilt speed of the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md).

Returns: The speed at which the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) is rotating around its [`Focus`](https://rapi.sleaze.dev/classes/Camera.md) around the camera's **X** axis.

### Interpolate

```luau
Camera:Interpolate(endPos: CFrame, endFocus: CFrame, duration: number)
```

- Tags: Deprecated, Capabilities: Basic

**Deprecated:** This method has been deprecated. Instead use [`TweenService`](https://rapi.sleaze.dev/classes/TweenService.md) to smoothly animate the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md), see the code snippets below for an example.

Tweens the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) in a linear fashion towards a new [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) and [`Focus`](https://rapi.sleaze.dev/classes/Camera.md) over a given duration.

Parameters:

- `endPos`: The [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) for the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) to tween to.
- `endFocus`: The [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) for the camera's [`Focus`](https://rapi.sleaze.dev/classes/Camera.md) to tween to.
- `duration`: The duration, in seconds, of the tween.

### PanUnits

```luau
Camera:PanUnits(units: number)
```

- Tags: Deprecated, Capabilities: Basic

**Deprecated:** This method was used for legacy camera controls and has since been deprecated. Do not use in new work.

Pans the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) around the [`Focus`](https://rapi.sleaze.dev/classes/Camera.md) in 45 degree increments around the **Y** axis.

Parameters:

- `units`: The number of 45 degree increments by which to pan the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md).

### SetCameraPanMode

```luau
Camera:SetCameraPanMode(mode: Enum.CameraPanMode? = Enum.CameraPanMode.Classic)
```

- Tags: Deprecated, Capabilities: Basic

**Deprecated:** This method has been deprecated and should not be used in new work.

Sets the `CameraPanMode` to be used by the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) on mobile devices.

Parameters:

- `mode`: The `CameraPanMode` to set the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) to.

### TiltUnits

```luau
Camera:TiltUnits(units: number): boolean
```

- Tags: Deprecated, Capabilities: Basic

**Deprecated:** This method was used for legacy camera controls and has been deprecated. Do not use in new work.

Tilts the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) around its [`Focus`](https://rapi.sleaze.dev/classes/Camera.md) in 10 degree increments around the camera's **X** axis.

Parameters:

- `units`: The number of 10 degree units by which to tilt the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md).

Returns: Whether the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) tilt applied was constrained.

## Events

### FirstPersonTransition

```luau
Camera.FirstPersonTransition: RBXScriptSignal<(entering: boolean)>
```

- Tags: Local user security, Capabilities: Basic

### InterpolationFinished

```luau
Camera.InterpolationFinished: RBXScriptSignal<()>
```

- Tags: Capabilities: Basic

Fired when the [`Camera`](https://rapi.sleaze.dev/classes/Camera.md) has finished interpolating using[`Interpolate()`](https://rapi.sleaze.dev/classes/Camera.md).

## Inherited members

- From [PVInstance](https://rapi.sleaze.dev/classes/PVInstance.md): `Pivot Offset`, `Origin`, `GetPivot`, `PivotTo`
- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
