Camera
The Camera object defines a view of the 3D world. In a running experience, each client has its own Camera object which resides in that client's local Workspace, accessible through the Workspace.CurrentCamera property.
The most important camera properties are:
CFrame which represents the position and orientation of the camera.
CameraType which is read by the experience's camera scripts and determines how the camera should update each frame.
CameraSubject which is read by the experience's camera scripts and determines what object the camera should follow.
FieldOfView which represents the visible extent of the observable world.
Focus which represents the point the camera is looking at. It's important this property is set, as certain visuals will be more detailed and will update more frequently depending on how close they are to the focus point.
See Customizing the Camera for more information on how to adjust and customize the camera's behavior.
Storing Multiple Cameras
Note that when changing Workspace.CurrentCamera to a new Camera, all other Cameras directly descending from Workspace will be destroyed. If you need to store multiple cameras and swap between them on demand, it's recommended that you store them in a Folder or Model under Workspace, inside which they will remain even when CurrentCamera is changed.
Summary
Properties
The CFrame of the Camera, defining its position and orientation in the 3D world.
Specifies the Enum.CameraType to be read by the camera scripts.
Sets the angle of the camera's diagonal field of view.
Sets the angle of the camera's vertical field of view.
Determines the FOV value of the Camera that's invariant under viewport size changes.
Sets the area in 3D space that is prioritized by Roblox's graphical systems.
Toggles whether the camera will automatically track the head motion of a player using a VR device.
Sets the scale of the user's perspective of the world when using VR.
Sets the angle of the camera's field of view along the longest viewport axis.
Describes the negative Z offset, in studs, of the camera's near clipping plane.
Toggles whether to apply tilt and roll from the CFrame property while the player is using a VR device.
The dimensions of the device safe area on a Roblox client.
Properties
Methods
Returns an array of BaseParts that are obscuring the lines of sight between the camera's CFrame and the cast points.
Returns the actual CFramewhere the Camera is being rendered, accounting for any roll applied and the impact of VR devices.
Returns in radians the current roll, or rotation around the camera's Z-axis, applied to the Camera using SetRoll().
Creates a unit Ray from a position on the screen (in pixels), at a set depth from the Camera orientated in the camera's direction. Accounts for the GUI inset.
Sets the current rotation applied around the camera's Z-axis.
Creates a unit Ray from a position on the viewport (in pixels), at a given depth from the Camera, orientated in the camera's direction. Does not account for the CoreUISafeInsets inset.
Returns the screen location and depth of a Vector3 worldPoint and whether this point is within the bounds of the screen. Accounts for the GUI inset.
Returns the screen location and depth of a Vector3 worldPoint and whether this point is within the bounds of the screen. Does not account for the GUI inset.
Methods
Gets the pivot of a PVInstance.
Transforms the PVInstance along with all of its descendant PVInstances such that the pivot is now located at the specified CFrame.
Events
Fired when the Camera has finished interpolating usingInterpolate().
Properties
Methods
GetRoll
Returns
Code Samples
local currentRoll = math.deg(workspace.CurrentCamera:GetRoll()) -- Gets the current roll of the camera in degrees.
if currentRoll ~= 20 then
workspace.CurrentCamera:SetRoll(math.rad(20)) -- If the camera isn't at 20 degrees roll, the roll is set to 20 degrees.
end