PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

Camera

Show deprecated

Camera

Show deprecated

The Camera object defines a view of the 3D game world.

Where the Camera object is found

In an instance of the game, each client has its own Camera object associated with it. Camera objects exist only upon the viewer’s client, residing in that user’s local Workspace, and therefore cannot be edited directly from the server.

Each client’s particular Camera object can be accessed through the Workspace/CurrentCamera property of the Workspace on that client.

Note, Workspace/CurrentCamera can also be used to find the Camera object in Roblox Studio.

How the Camera object works

The Camera’s properties define the current view of the 3D game world. The most important of these being:

  • The Camera/CFrame property represents the position and orientation of the camera.
  • The Camera/Focus property represents the point the camera is looking at. It is important this property is set as it also represents where the game thinks you are in the world. Certain visuals will be more detailed and will update more frequently, depending on how close they are to the Focus. Roblox’s default camera scripts take care of this.
  • The Camera/CameraType property is read by the game’s camera scripts and determines how the Camera should update each frame.
  • The Camera/CameraSubject property is read by the game’s camera scripts and determines what object the Camera should follow.
  • The Camera/FieldOfView property represents the extent of the observable world visible.

How to work with the Camera

Roblox’s camera scripts update the Camera’s properties every frame dependent on the current Camera/CameraType. This means developers looking to control the Camera themselves have two options.

  1. Setting the Camera/CameraType property to ‘Scriptable’. When the Camera is in ‘Scriptable’ mode the default camera scripts will not update the camera. In most cases this is the easiest option.
  2. Replacing or modifying the default camera scripts in StarterPlayerScripts|StarterPlayer.StarterPlayerScripts. This is only recommended for advanced developers.

Properties

CFrame

CFrame

The DataType/CFrame of the Camera, defining its position and orientation in the 3D world

Instance

CameraSubject

The Humanoid or BasePart that is the Camera|Camera's subject

CameraType

CameraType

Specifies the Enum/CameraType to be read by the camera scripts

CFrame

CoordinateFrame

[Hidden] [NotReplicated] [Deprecated]

The old version of the Camera/CFrame property which functions identically to it.

This item should be used in a LocalScript in order to work as expected online.

float

FieldOfView

Sets the angle of the Camera|Camera's vertical field of view

CFrame

Focus

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

bool

HeadLocked

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

float

HeadScale

Sets the scale of the user’s head when using VR

float

NearPlaneZ

[ReadOnly] [NotReplicated]

Describes the negative z-offset, in studs, of the Camera|Camera's near clipping plane

Vector2

ViewportSize

[ReadOnly] [NotReplicated]

Describes the dimensions, in pixels, of the client’s viewport

CFrame

focus

[NotReplicated] [Deprecated]

Inherited from Instance: Show Hide

bool

Archivable

Determines if an Instance can be cloned using /Instance/Clone or saved to file.

string

ClassName

[ReadOnly] [NotReplicated]

A read-only string representing the class this Instance belongs to

int

DataCost

[ReadOnly] [NotReplicated] [Deprecated]

The cost of saving the instance using data persistence.

string

Name

A non-unique identifier of the Instance

Instance

Parent

Determines the hierarchical parent of the Instance

bool

RobloxLocked

If true, the Instance and its descendants cannot be indexed or edited by a Script or LocalScript and will throw an error if it is attempted

bool

archivable

[Hidden] [NotReplicated] [Deprecated]
string

className

[ReadOnly] [NotReplicated] [Deprecated]

Functions

float

GetLargestCutoffDistance ( Objects ignoreList )

Returns how much the Camera needs to be pushed towards its Camera/Focus|Focus in order to make sure there is no obstructions between the Camera/Focus and Camera/CFrame

float

GetPanSpeed ( )

Returns the current ‘pan’ speed of the Camera

Objects

GetPartsObscuringTarget ( Array castPoints , Objects ignoreList )

Returns an array of BasePart|BaseParts that are obscuring the lines of sight between the Camera|Camera’s Camera/CFrame and the castPoints

CFrame

GetRenderCFrame ( )

Returns the actual DataType/CFramewhere the Camera is being rendered, accounting for any roll applied and the impact of VR devices

float

GetRoll ( )

Returns in radians the current roll, or rotation around the Camera|Camera’s Z-axis, applied to the Camera using Camera/SetRoll

float

GetTiltSpeed ( )

Returns the current ‘tilt’ speed of the Camera

void

Interpolate ( CFrame endPos , CFrame endFocus , float duration )

Tweens the Camera in a linear fashion towards a new Camera/CFrame and Camera/Focus over a given duration

void

PanUnits ( int units )

Pans the Camera around the Camera/Focus in 45 degree increments around the Y axis

Ray

ScreenPointToRay ( float x , float y , float depth )

Creates a unit DataType/Ray from a position on the screen (in pixels), at a set depth from the Camera orientated in the Camera|Camera’s direction. Accounts for the GUI inset

void

SetCameraPanMode ( CameraPanMode mode )

Sets the Enum/CameraPanMode to be used by the Camera on mobile devices

void

SetRoll ( float rollAngle )

Sets the current rotation applied around the Camera|Camera’s Z-axis

bool

TiltUnits ( int units )

Tilts the Camera around its Camera/Focus in 10 degree increments around the Camera|Camera’s X axis

Ray

ViewportPointToRay ( float x , float y , float depth )

Creates a unit DataType/Ray from a position on the viewport (in pixels), at a given depth from the Camera orientated in the Camera|Camera’s direction. Does not account for the GUI inset

Tuple

WorldToScreenPoint ( Vector3 worldPoint )

Returns the 2D screen location of a DataType/Vector3 position in the world, the depth of it from the screen and whether it is visible. Accounts for the GUI inset

Tuple

WorldToViewportPoint ( Vector3 worldPoint )

Returns the 2D screen location of a DataType/Vector3 position in the world, but does not account for the GUI inset

Inherited from Instance: Show Hide

void

ClearAllChildren ( )

This function destroys all of an Instance's children.

Instance

Clone ( )

Create a deep copy of a Roblox instance and descendants where Archivable = true.

void

Destroy ( )

Sets the Instance/Parent property to nil, locks the Instance/Parent property, disconnects all connections and calls Destroy on all children.

Instance

FindFirstAncestor ( string name )

Returns the first ancestor of the Instance whose Instance/Name is equal to the given name.

Instance

FindFirstAncestorOfClass ( string className )

Returns the first ancestor of the Instance whose Instance/ClassName is equal to the given className.

Instance

FindFirstAncestorWhichIsA ( string className )

Returns the first ancestor of the Instance for whom Instance/IsA returns true for the given className.

Instance

FindFirstChild ( string name , bool recursive )

Returns the first child of the Instance found with the given name.

Instance

FindFirstChildOfClass ( string className )

Returns the first child of the Instance whose Instance/ClassName|ClassName is equal to the given className.

Instance

FindFirstChildWhichIsA ( string className , bool recursive )

Returns the first child of the Instance for whom Instance/IsA returns true for the given className.

Variant

GetAttribute ( string attribute )

RBXScriptSignal

GetAttributeChangedSignal ( string attribute )

Dictionary

GetAttributes ( )

Objects

GetChildren ( )

Returns an array containing all of the Instance's children.

string

GetDebugId ( int scopeLength )

[NotBrowsable]

Returns a coded string of the Instances DebugId used internally by Roblox.

Array

GetDescendants ( )

[CustomLuaState]

Returns an array containing all of the descendants of the instance

string

GetFullName ( )

Returns a string describing the Instance's ancestry.

RBXScriptSignal

GetPropertyChangedSignal ( string property )

Get an event that fires when a given property of an object changes.

bool

IsA ( string className )

[CustomLuaState]

Returns true if an Instance's class matches or inherits from a given class

bool

IsAncestorOf ( Instance descendant )

Returns true if an Instance is an ancestor of the given descendant.

bool

IsDescendantOf ( Instance ancestor )

Returns true if an Instance is a descendant of the given ancestor.

void

Remove ( )

[Deprecated]

Sets the object’s Parent to nil, and does the same for all its descendants.

void

SetAttribute ( string attribute , Variant value )

Instance

WaitForChild ( string childName , double timeOut )

[CustomLuaState] [CanYield]

Returns the child of the Instance with the given name. If the child does not exist, it will yield the current thread until it does.

Objects

children ( )

[Deprecated]

Returns an array of the object’s children.

Instance

clone ( )

[Deprecated]
void

destroy ( )

[Deprecated]
Instance

findFirstChild ( string name , bool recursive )

[Deprecated]
Objects

getChildren ( )

[Deprecated]
bool

isA ( string className )

[Deprecated] [CustomLuaState]
bool

isDescendantOf ( Instance ancestor )

[Deprecated]
void

remove ( )

[Deprecated]

Events

RBXScriptSignal

FirstPersonTransition ( bool entering )

Fires when the local user’s Camera switches in and out of first person mode

RBXScriptSignal

InterpolationFinished ( )

Fired when the Camera has finished interpolating usingCamera/Interpolate

Inherited from Instance: Show Hide

RBXScriptSignal

AncestryChanged ( Instance child , Instance parent )

Fires when the Instance/Parent property of the object or one of its ancestors is changed.

RBXScriptSignal

AttributeChanged ( string attribute )

RBXScriptSignal

Changed ( string property )

Fired immediately after a property of an object changes.

RBXScriptSignal

ChildAdded ( Instance child )

Fires when an object is parented to this Instance.

RBXScriptSignal

ChildRemoved ( Instance child )

Fires when a child is removed from this Instance.

RBXScriptSignal

DescendantAdded ( Instance descendant )

Fires when a descendant is added to the Instance

RBXScriptSignal

DescendantRemoving ( Instance descendant )

Fires immediately before a descendant of the Instance is removed.

RBXScriptSignal

childAdded ( Instance child )

[Deprecated]