FANDOM


The Camera class represents a view of the game world. The Camera class inherits from Instance.

Camera objects are not replicated to the server and exist only on the client of each player. Because they are stored locally, they cannot be accessed by ExplorerImageIndex 6Scripts; ExplorerImageIndex 18LocalScript must be used instead to get the player's camera. The player's local camera can be given by the CurrentCamera property of ExplorerImageIndex 19Workspace.

Game developers can create parts that can only be seen by one player via the camera by putting parts within the camera. Only the player will collide with such parts, and such parts cannot be removed using a Script.

Scripts and LocalScripts placed into the camera do not run. Such things can only happen to parts in cameras if they are controlled by a LocalScript elsewhere.

Properties

Pubfield CFrame CFrame

The current position and rotation of the Camera. For most CameraTypes, the rotation is set such that the CoordinateFrame lookVector is pointing at the Focus.

Category: Data.

Serialization: can save and load.

Pubfield Instance CameraSubject

Where the Camera's focus is. Any rotation of the camera will be about this subject.

Category: Camera.

Serialization: can save and load.

Pubfield CameraType CameraType

Defines how the camera will behave.

Category: Camera.

Serialization: can save and load.

Pubfield CFrame CoordinateFrame

The current position and rotation of the Camera. For most CameraTypes, the rotation is set such that the CoordinateFrame lookVector is pointing at the Focus.

Category: Data.

Serialization: can load only.

Tags: Hidden, NotReplicated, Deprecated.

Pubfield float FieldOfView

The current angle, or width, of what the camera can see. Current acceptable values are from 20 degrees to 80.

Category: Data.

Serialization: can save and load.

Pubfield CFrame Focus

The current CoordinateFrame that the camera is looking at. Note: it is not guaranteed that the camera is always looking here.

Category: Data.

Serialization: can save and load.

Pubfield bool HeadLocked

Category: Data.

Serialization: can save and load.

Pubfield float HeadScale

Category: Data.

Serialization: can save and load.

Pubfield float NearPlaneZ

The negative z-offset of the view frustum's near clipping plane.

Category: Data.

Serialization: can save only.

Tags: ReadOnly, NotReplicated.

Pubfield Vector2 ViewportSize

Holds the x,y screen resolution of the viewport the camera is presenting (note: this can differ from the AbsoluteSize property of a full screen gui).

Category: Data.

Serialization: can save only.

Tags: ReadOnly, NotReplicated.

Pubfield CFrame focus

Category: Data.

Serialization: can load only.

Tags: NotReplicated, Deprecated.

Functions

Pubmethod float GetLargestCutoffDistance(Objects ignoreList)

Pubmethod float GetPanSpeed()

Pubmethod Objects GetPartsObscuringTarget(Array castPoints, Objects ignoreList)

Pubmethod CFrame GetRenderCFrame()

Pubmethod float GetRoll()

Returns the camera's current roll. Roll is defined in radians, and is stored as the delta from the camera's y axis default normal vector.

Pubmethod float GetTiltSpeed()

Pubmethod void Interpolate(CFrame endPos, CFrame endFocus, float duration)

Pubmethod void PanUnits(int units)

Pubmethod Ray ScreenPointToRay(float x, float y, float depth = 0)

Takes a 2D screen position and produces a Ray object to be used for 3D raycasting. Input is x,y screen coordinates, and a (optional, defaults to 0) z position which sets how far in the camera look vector to start the ray origin.

Pubmethod void SetCameraPanMode(CameraPanMode mode = Classic)

Pubmethod void SetRoll(float rollAngle)

Sets the camera's current roll. Roll is defined in radians, and is stored as the delta from the camera's y axis default normal vector.

Pubmethod bool TiltUnits(int units)

Pubmethod Ray ViewportPointToRay(float x, float y, float depth = 0)

Same as ScreenPointToRay, except no GUI offsets are taken into account. Useful for things like casting a ray from the middle of the Camera.ViewportSize

Pubmethod Tuple WorldToScreenPoint(Vector3 worldPoint)

Takes a 3D position in the world and projects it onto x,y coordinates of screen space. Returns two values, first is a Vector3 that has x,y position and z position which is distance from camera (negative if behind camera, positive if in front). Second return value is a boolean indicating if the first argument is an on-screen coordinate.

Pubmethod Tuple WorldToViewportPoint(Vector3 worldPoint)

Same as WorldToScreenPoint, except no GUI offsets are taken into account.

Protmethod bool Zoom(float distance)

Security: RobloxScriptSecurity.

Events

Protevent FirstPersonTransition(bool entering)

Security: LocalUserSecurity.

Pubevent InterpolationFinished()

External links

Community content is available under CC-BY-SA unless otherwise noted.