Camera
A class which defines a view of the 3D world.
Memory category | Instances |
---|
Member index 35
Removed member index 1
History | Member | |
---|---|---|
118 | SetCameraInputMode(mode: CameraInputMode = Classic): void |
Description
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:
Camera.CFrame which represents the position and orientation of the camera.
Camera.CameraType which is read by the experience's camera scripts and determines how the camera should update each frame.
Camera.CameraSubject which is read by the experience's camera scripts and determines what object the camera should follow.
Camera.FieldOfView which represents the visible extent of the observable world.
Camera.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.
History 141
- 598 Change Tags of SetCameraPanMode from [] to [Deprecated]
- 582 Change Tags of GetTiltSpeed from [] to [Deprecated]
- 582 Change Tags of GetPanSpeed from [] to [Deprecated]
- 580 Change Default of MaxAxisFieldOfView from 70.0000076 to 70
- 580 Change Default of FieldOfView from 70.0000076 to 70
- 580 Change Default of DiagonalFieldOfView from 88.8765259 to 88.8765335
- 577 Add VRTiltAndRollEnabled
- 573 Change ReturnType of ZoomToExtents from void to null
- 573 Change ReturnType of SetRoll from void to null
- 573 Change ReturnType of SetImageServerView from void to null
- 573 Change ReturnType of SetCameraPanMode from void to null
- 573 Change ReturnType of PanUnits from void to null
- 573 Change ReturnType of Interpolate from void to null
- 562 Add ZoomToExtents
- 553 Change PreferredDescriptor of focus from to Focus
- 553 Change Default of focus from to
- 553 Change Default of ViewportSize from to Vector2(1, 1)
- 553 Change Default of NearPlaneZ from to -0.5
- 553 Change Default of MaxAxisFieldOfView from to 70.0000076
- 553 Change Default of HeadScale from to 1
- 553 Change Default of HeadLocked from to true
- 553 Change Default of Focus from to
- 553 Change Default of FieldOfViewMode from to Vertical
- 553 Change Default of FieldOfView from to 70.0000076
- 553 Change Default of DiagonalFieldOfView from to 88.8765259
- 553 Change PreferredDescriptor of from to CFrame
- 553 Change Default of from to
- 553 Change Default of CameraType from to Fixed
- 553 Change Default of CameraSubject from to
- 553 Change Default of CFrame from to
- 486 Change ThreadSafety of WorldToViewportPoint from Unsafe to Safe
- 486 Change ThreadSafety of WorldToScreenPoint from Unsafe to Safe
- 486 Change ThreadSafety of ViewportPointToRay from Unsafe to Safe
- 486 Change ThreadSafety of ScreenPointToRay from Unsafe to Safe
- 486 Change ThreadSafety of focus from ReadOnly to ReadSafe
- 486 Change ThreadSafety of ViewportSize from ReadOnly to ReadSafe
- 486 Change ThreadSafety of NearPlaneZ from ReadOnly to ReadSafe
- 486 Change ThreadSafety of MaxAxisFieldOfView from ReadOnly to ReadSafe
- 486 Change ThreadSafety of HeadScale from ReadOnly to ReadSafe
- 486 Change ThreadSafety of HeadLocked from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Focus from ReadOnly to ReadSafe
- 486 Change ThreadSafety of FieldOfViewMode from ReadOnly to ReadSafe
- 486 Change ThreadSafety of FieldOfView from ReadOnly to ReadSafe
- 486 Change ThreadSafety of DiagonalFieldOfView from ReadOnly to ReadSafe
- 486 Change ThreadSafety of from ReadOnly to ReadSafe
- 486 Change ThreadSafety of CameraType from ReadOnly to ReadSafe
- 486 Change ThreadSafety of CameraSubject from ReadOnly to ReadSafe
- 486 Change ThreadSafety of CFrame from ReadOnly to ReadSafe
- 462 Change ThreadSafety of InterpolationFinished from to Unsafe
- 462 Change ThreadSafety of FirstPersonTransition from to Unsafe
- 462 Change ThreadSafety of Zoom from to Unsafe
- 462 Change ThreadSafety of WorldToViewportPoint from to Unsafe
- 462 Change ThreadSafety of WorldToScreenPoint from to Unsafe
- 462 Change ThreadSafety of ViewportPointToRay from to Unsafe
- 462 Change ThreadSafety of TiltUnits from to Unsafe
- 462 Change ThreadSafety of SetRoll from to Unsafe
- 462 Change ThreadSafety of SetImageServerView from to Unsafe
- 462 Change ThreadSafety of SetCameraPanMode from to Unsafe
- 462 Change ThreadSafety of ScreenPointToRay from to Unsafe
- 462 Change ThreadSafety of PanUnits from to Unsafe
- 462 Change ThreadSafety of Interpolate from to Unsafe
- 462 Change ThreadSafety of GetTiltSpeed from to Unsafe
- 462 Change ThreadSafety of GetRoll from to Unsafe
- 462 Change ThreadSafety of GetRenderCFrame from to Unsafe
- 462 Change ThreadSafety of GetPartsObscuringTarget from to Unsafe
- 462 Change ThreadSafety of GetPanSpeed from to Unsafe
- 462 Change ThreadSafety of GetLargestCutoffDistance from to Unsafe
- 462 Change ThreadSafety of focus from to ReadOnly
- 462 Change ThreadSafety of ViewportSize from to ReadOnly
- 462 Change ThreadSafety of NearPlaneZ from to ReadOnly
- 462 Change ThreadSafety of MaxAxisFieldOfView from to ReadOnly
- 462 Change ThreadSafety of HeadScale from to ReadOnly
- 462 Change ThreadSafety of HeadLocked from to ReadOnly
- 462 Change ThreadSafety of Focus from to ReadOnly
- 462 Change ThreadSafety of FieldOfViewMode from to ReadOnly
- 462 Change ThreadSafety of FieldOfView from to ReadOnly
- 462 Change ThreadSafety of DiagonalFieldOfView from to ReadOnly
- 462 Change ThreadSafety of from to ReadOnly
- 462 Change ThreadSafety of CameraType from to ReadOnly
- 462 Change ThreadSafety of CameraSubject from to ReadOnly
- 462 Change ThreadSafety of CFrame from to ReadOnly
- 452 Change Tags of MaxAxisFieldOfView from [] to [NotReplicated]
- 452 Change CanSave of MaxAxisFieldOfView from true to false
- 452 Change CanLoad of MaxAxisFieldOfView from true to false
- 452 Change Tags of DiagonalFieldOfView from [] to [NotReplicated]
- 452 Change CanSave of DiagonalFieldOfView from true to false
- 452 Change CanLoad of DiagonalFieldOfView from true to false
- 450 Add MaxAxisFieldOfView
- 450 Add FieldOfViewMode
- 450 Change Category of FieldOfView from Data to Camera
- 450 Add DiagonalFieldOfView
- 422 Change Tags of TiltUnits from [] to [Deprecated]
- 422 Change Tags of PanUnits from [] to [Deprecated]
- 422 Change Tags of Interpolate from [] to [Deprecated]
- 422 Change Tags of GetLargestCutoffDistance from [] to [Deprecated]
- 396 Add SetImageServerView
- 329 Change ValueType of CameraSubject from Object to Instance
- 327 Add NearPlaneZ
- 311 Change Security of FirstPersonTransition from RobloxPlaceSecurity to LocalUserSecurity
- 281 Add GetPartsObscuringTarget
- 281 Add GetLargestCutoffDistance
- 240 Add HeadScale
- 234 Add GetRenderCFrame
- 234 Add HeadLocked
- 230 Change Tags of from [NotReplicated] to [Hidden, NotReplicated, Deprecated]
- 230 Add CFrame
- 190 Add WorldToViewportPoint
- 190 Add ViewportPointToRay
- 189 Add WorldToScreenPoint
- 189 Add ScreenPointToRay
- 189 Add ViewportSize
- 188 Remove WorldToScreenPoint
- 188 Remove ScreenPointToRay
- 188 Remove ViewportSize
- 189 Add WorldToScreenPoint
- 189 Add ScreenPointToRay
- 189 Add ViewportSize
- 118 Change Security of TiltUnits from RobloxScriptSecurity to None
- 118 Add SetCameraPanMode
- 118 Remove SetCameraInputMode
- 118 Change Security of PanUnits from RobloxScriptSecurity to None
- 118 Change Security of GetTiltSpeed from RobloxPlaceSecurity to None
- 118 Change Security of GetPanSpeed from RobloxPlaceSecurity to None
- 113 Add FirstPersonTransition
- 113 Add SetCameraInputMode
- 113 Add GetTiltSpeed
- 113 Add GetPanSpeed
- 94 Add InterpolationFinished
- 94 Add Interpolate
- 57 Add focus
- 55 Add SetRoll
- 55 Add GetRoll
- 50 Add FieldOfView
- 47 Add Zoom
- 47 Add TiltUnits
- 47 Add PanUnits
- 47 Add Focus
- 47 Add
- 47 Add CameraType
- 47 Add CameraSubject
- 47 Add Camera
Members 35
CFrame
Type | Default | |
---|---|---|
CFrame |
This property is the CFrame of the Camera, defining its position and orientation in the 3D world. Note that some transformations, such as the rotation of the head when using VR devices, are not reflected in this property, so you should use GetRenderCFrame() to obtain the "true" CFrame of the camera.
You can move the camera by setting this property. However, the default camera scripts also set it, so you should either:
Set the camera Camera.CameraType to CameraType.Scriptable so that the default camera scripts will not update the camera's CFrame. This method is simplest and recommended in most cases.
Completely replace the default camera scripts with alternatives. This approach is only recommended if you do not need any default camera functionality.
The most intuitive way to position and orient the Camera is by using the CFrame.lookAt() constructor. In the following example, the Camera is positioned at Vector3.new(0, 10, 0) and is oriented to be looking towards Vector3.new(10, 0, 0).
1 2 3 4 5 6 7 |
|
Although the camera can be placed in the manner demonstrated above, you may want to animate it to move smoothly from one CFrame to another. For this, you can either:
Set the camera's position/orientation every frame with RunService:BindToRenderStep() and the CFrame:Lerp() method.
Create and play a Tween that animates the position/orientation of the camera:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
local Players = game:GetService("Players") local TweenService = game:GetService("TweenService") local camera = workspace.CurrentCamera camera.CameraType = Enum.CameraType.Scriptable local player = Players.LocalPlayer local character = player.Character if not character or character.Parent == nil then character = player.CharacterAdded:Wait() end local pos = camera.CFrame * Vector3.new(0, 20, 0) local lookAtPos = character.PrimaryPart.Position local targetCFrame = CFrame.lookAt(pos, lookAtPos) local tween = TweenService:Create(camera, TweenInfo.new(2), {CFrame = targetCFrame}) tween:Play()
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true |
CameraSubject
Type | Default | |
---|---|---|
Instance |
CameraSubject accepts a variety of Instances. The default camera scripts respond differently to the available settings:
By default, the camera scripts follow the local character's Humanoid, factoring in the humanoid's current state and Humanoid.CameraOffset.
When set to a BasePart, the camera scripts follow its position, with a vertical offset in the case of VehicleSeats.
CameraSubject cannot be set to nil
. Attempting to do so will revert
it to its previous value.
To restore CameraSubject to its default value, set it to the local character's Humanoid:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Thread safety | ReadSafe |
---|---|
Category | Camera |
Loaded/Saved | true |
History 5
- 553 Change Default of CameraSubject from to
- 486 Change ThreadSafety of CameraSubject from ReadOnly to ReadSafe
- 462 Change ThreadSafety of CameraSubject from to ReadOnly
- 329 Change ValueType of CameraSubject from Object to Instance
- 47 Add CameraSubject
CameraType
Type | Default | |
---|---|---|
CameraType | Fixed |
The default Roblox camera scripts have several built-in behaviors. Setting this property toggles between the various CameraType behaviors. Note that some camera types require a valid Camera.CameraSubject to work correctly.
The default camera scripts will not move or update the camera if CameraType is set to CameraType.Scriptable. For more information on positioning and orienting the camera manually, see Camera.CFrame.
For all CameraType settings except CameraType.Scriptable, the CameraSubject property represents the object whose position the camera's Camera.Focus is set to.
Thread safety | ReadSafe |
---|---|
Category | Camera |
Loaded/Saved | true |
History 4
- 553 Change Default of CameraType from to Fixed
- 486 Change ThreadSafety of CameraType from ReadOnly to ReadSafe
- 462 Change ThreadSafety of CameraType from to ReadOnly
- 47 Add CameraType
DiagonalFieldOfView
Type | Default | |
---|---|---|
float | 88.8765335 |
Sets how many degrees in the diagonal direction (from one corner of the viewport to its opposite corner) the camera can view. See FieldOfView for a more general explanation of field of view.
Thread safety | ReadSafe |
---|---|
Category | Camera |
Loaded/Saved | false |
History 8
- 580 Change Default of DiagonalFieldOfView from 88.8765259 to 88.8765335
- 553 Change Default of DiagonalFieldOfView from to 88.8765259
- 486 Change ThreadSafety of DiagonalFieldOfView from ReadOnly to ReadSafe
- 462 Change ThreadSafety of DiagonalFieldOfView from to ReadOnly
- 452 Change Tags of DiagonalFieldOfView from [] to [NotReplicated]
- 452 Change CanSave of DiagonalFieldOfView from true to false
- 452 Change CanLoad of DiagonalFieldOfView from true to false
- 450 Add DiagonalFieldOfView
FieldOfView
Type | Default | |
---|---|---|
float | 70 |
The FieldOfView property sets how many degrees in the vertical direction the camera can view. This property is clamped between 1 and 120 degrees and defaults at 70. Very low or very high fields of view are not recommended as they can be disorientating to players.
Note that uniform scaling is enforced, meaning the vertical and horizontal field of view are always related by the aspect ratio of the screen.
Suggested uses for FieldOfView (FOV) include:
- Reducing FOV to give the impression of magnification, for example when using binoculars.
- Increasing FOV when the player is "sprinting" to give the impression of a lack of control.
Thread safety | ReadSafe |
---|---|
Category | Camera |
Loaded/Saved | true |
History 6
- 580 Change Default of FieldOfView from 70.0000076 to 70
- 553 Change Default of FieldOfView from to 70.0000076
- 486 Change ThreadSafety of FieldOfView from ReadOnly to ReadSafe
- 462 Change ThreadSafety of FieldOfView from to ReadOnly
- 450 Change Category of FieldOfView from Data to Camera
- 50 Add FieldOfView
FieldOfViewMode
Type | Default | |
---|---|---|
FieldOfViewMode | Vertical |
The camera's field of view (FOV) must be updated to reflect ViewportSize changes. The value of FieldOfViewMode determines which FOV value will be kept constant.
For example, when this property is set to FieldOfViewMode.Vertical, the horizontal FOV is updated when the viewport is resized, but the vertical FOV is kept constant. If this property is set to FieldOfViewMode.Diagonal, both horizontal and vertical FOV might be changed to keep the diagonal FOV constant.
Thread safety | ReadSafe |
---|---|
Category | Camera |
Loaded/Saved | true |
History 4
- 553 Change Default of FieldOfViewMode from to Vertical
- 486 Change ThreadSafety of FieldOfViewMode from ReadOnly to ReadSafe
- 462 Change ThreadSafety of FieldOfViewMode from to ReadOnly
- 450 Add FieldOfViewMode
FirstPersonTransition
Parameters (1) | |
---|---|
entering | bool |
Security | LocalUserSecurity |
---|---|
Thread safety | Unsafe |
History 3
- 462 Change ThreadSafety of FirstPersonTransition from to Unsafe
- 311 Change Security of FirstPersonTransition from RobloxPlaceSecurity to LocalUserSecurity
- 113 Add FirstPersonTransition
Focus
Type | Default | |
---|---|---|
CFrame |
Certain graphical operations the engine performs, such as updating lighting, can take time or computational effort to complete. The camera's Focus property tells the engine which area in 3D space to prioritize when performing such operations. For example, dynamic lighting from objects such as PointLights may not render at distances far from the focus.
The default Roblox camera scripts automatically set Focus to follow the Camera.CameraSubject (usually a Humanoid). However, Focus will not automatically update when CameraType is set to CameraType.Scriptable or when the default camera scripts are not being used. In these cases, you should update Focus every frame, using RunService:BindToRenderStep() function at the RenderPriority.Camera priority.
Focus has no bearing on the position or orientation of the camera; see Camera.CFrame for this.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true |
GetLargestCutoffDistance
Parameters (1) | ||
---|---|---|
ignoreList | Objects | |
Returns (1) | ||
float |
This function is used by 'PopperCam' in the default camera scripts to ensure obstructions do not come between the Camera and its subject.
This function will check all BaseParts and Terrain in the Workspace with the following exceptions:
- Any Instance specified in the ignoreList (including its descendants) will be ignored
- BaseParts with BasePart.CanCollide set to false are ignored
- BaseParts with a BasePart.Transparency greater than 0.95 will be ignored Water Terrain is ignored
Note, as this function requires an ignoreList to run, you should pass an empty table when none is required.
Thread safety | Unsafe |
---|
History 3
- 462 Change ThreadSafety of GetLargestCutoffDistance from to Unsafe
- 422 Change Tags of GetLargestCutoffDistance from [] to [Deprecated]
- 281 Add GetLargestCutoffDistance
GetPanSpeed
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
float |
This function is broken and should not be used This function returns the current 'pan' speed of the Camera.
The 'pan' speed of the Camera describes the speed at which the Camera is rotating around its Camera.Focus around the Y axis.
See also:
- Camera:GetTiltSpeed() for the speed at which the Camera is rotating around its Camera.Focus on the camera's X axis
- Camera:PanUnits() to 'pan' the camera
- Camera:TiltUnits() to 'tilt' the camera
Thread safety | Unsafe |
---|
History 4
- 582 Change Tags of GetPanSpeed from [] to [Deprecated]
- 462 Change ThreadSafety of GetPanSpeed from to Unsafe
- 118 Change Security of GetPanSpeed from RobloxPlaceSecurity to None
- 113 Add GetPanSpeed
GetPartsObscuringTarget
Parameters (2) | ||
---|---|---|
castPoints | Array | |
ignoreList | Objects | |
Returns (1) | ||
Objects |
This method returns an array of BaseParts that are
obscuring the lines of sight between the camera's Camera.CFrame
and Vector3 positions in the castPoints
array. Any
Instances included in the ignoreList
array will be
ignored, along with their descendants.
The castPoints
parameter is given as an array of Vector3
positions. Note that the array of BaseParts returned is
in an arbitrary order, and no additional raycast data is provided. If you
need data such as hit position, hit material, or surface normal, you
should opt for the WorldRoot:Raycast() method.
1 2 3 4 5 6 7 8 9 |
|
If Terrain obscures a cast point, BaseParts obscuring the cast point between the obscuring Terrain and the cast point will not be returned.
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of GetPartsObscuringTarget from to Unsafe
- 281 Add GetPartsObscuringTarget
GetRenderCFrame
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
CFrame |
This function returns the actual CFrame of the Camera as it is rendered, including the impact of VR (VR head transformations are not applied to the Camera.CFrame property, so it is best practice to use Camera:GetRenderCFrame() to obtain the "true" CFrame of a player's view).
For example, when using VR, the Camera is actually rendered at the following CFrame:
1 2 3 4 5 6 7 |
|
The camera's render CFrame will only be changed to account for the head when the Camera.HeadLocked property is true.
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of GetRenderCFrame from to Unsafe
- 234 Add GetRenderCFrame
GetRoll
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
float |
This function returns, in radians, the current roll applied to the Camera using Camera:SetRoll(). Roll is defined as rotation around the camera's Z-axis.
This function only returns roll applied using the Camera:SetRoll() function. Roll manually applied to the camera's Camera.CFrame is not accounted for. To obtain the actual roll of the Camera, including roll manually applied, you can use the following snippet:
1 2 3 4 5 6 7 8 |
|
Thread safety | Unsafe |
---|
GetTiltSpeed
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
float |
This function is broken and should not be used.
This function returns the current 'tilt' speed of the Camera.
The 'tilt' speed of the Camera describes the speed at which the Camera is rotating around its Camera.Focus around the camera's X axis.
See also:
Camera:GetPanSpeed() for the speed the Camera is rotating around the Camera.Focus around the Y axis Camera:PanUnits() to 'pan' the camera Camera:TiltUnits() to 'tilt' the camera
Thread safety | Unsafe |
---|
History 4
- 582 Change Tags of GetTiltSpeed from [] to [Deprecated]
- 462 Change ThreadSafety of GetTiltSpeed from to Unsafe
- 118 Change Security of GetTiltSpeed from RobloxPlaceSecurity to None
- 113 Add GetTiltSpeed
HeadLocked
Type | Default | |
---|---|---|
bool | true |
Toggles whether the camera will automatically track the head motion of a
player using a VR device. When true
(default), the engine combines
Camera.CFrame with the UserCFrame of the user's head to
render the player's view with head tracking factored in. The view will be
rendered at the following CFrame:
1 2 3 4 5 6 7 8 9 |
|
It is recommended to not disable this property for the following reasons:
- Players may experience motion sickness if an equivalent head tracking solution is not added.
- The Roblox engine performs latency optimizations when HeadLocked is true.
See Also
- VRService:GetUserCFrame() which can be used to obtain the CFrame of the head.
- VRService:RecenterUserHeadCFrame() which is used to recenter the head to the current position and orientation of the VR device.
- The Camera:GetRenderCFrame() function which returns the Camera.CFrame combined with the CFrame of the user's head.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true |
History 4
- 553 Change Default of HeadLocked from to true
- 486 Change ThreadSafety of HeadLocked from ReadOnly to ReadSafe
- 462 Change ThreadSafety of HeadLocked from to ReadOnly
- 234 Add HeadLocked
HeadScale
Type | Default | |
---|---|---|
float | 1 |
HeadScale is the scale of the user's perspective of the world when using VR.
The size of 1 stud in VR is 0.3 meters / HeadScale
, meaning that larger
HeadScale values equate to the world looking smaller from the user's
perspective when using VR devices. For example, a part that's 1 stud tall
appears to be 0.6 meters tall to a VR player with a HeadScale of 0.5.
This property is automatically controlled by VRService.AutomaticScaling to align the player's perspective with the size of their avatar. If you intend to control HeadScale yourself or use custom characters, toggle VRService.AutomaticScaling to VRScaling.Off.
This property should not be confused with Humanoid.HeadScale which is a NumberValue parented to a Humanoid to control its scaling.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true |
Interpolate
Parameters (3) | ||
---|---|---|
endPos | CFrame | |
endFocus | CFrame | |
duration | float | |
Returns (1) | ||
null |
This function tweens the Camera in a linear fashion towards a new Camera.CFrame and Camera.Focus over a given duration, for example:
1 2 3 4 5 6 7 8 |
|
Throughout the tween, the camera's Camera.CFrame will be orientated towards the camera's Camera.Focus.
When the tween has completed, the camera's Camera.InterpolationFinished event will fire.
If this function is called while the Camera is already tweening the older tween will be stopped (without firing Camera.InterpolationFinished) and overridden by the new tween.
Interpolate can only be used if the current Camera.CameraType is 'Scriptable', regardless of whether the default camera scripts are being used. If it is used with any other Camera.CameraType an error will be thrown.
You are advised to use TweenService to tween the Camera instead as it is more reliable and offers a variety of easing styles. See below for an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Thread safety | Unsafe |
---|
History 4
- 573 Change ReturnType of Interpolate from void to null
- 462 Change ThreadSafety of Interpolate from to Unsafe
- 422 Change Tags of Interpolate from [] to [Deprecated]
- 94 Add Interpolate
InterpolationFinished
Parameters (0) | ||
---|---|---|
No parameters. |
This event fires when the Camera has finished interpolating using the Camera:Interpolate() function.
This event will not fire if a tween is interrupted due to Camera:Interpolate() being called again.
You are advised to use TweenService to animate the Camera instead, as it is more reliable and provides more options for easing styles.
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of InterpolationFinished from to Unsafe
- 94 Add InterpolationFinished
MaxAxisFieldOfView
Type | Default | |
---|---|---|
float | 70 |
The MaxAxisFieldOfView property sets how many degrees along the longest viewport axis the camera can view.
When the longest axis is the vertical axis, this property will behave similar to the FieldOfView property. This is generally the case when a device is in a portrait orientation. In a landscape orientation, the longest axis will be the horizontal axis; in this case, the property describes the horizontal field of view of the Camera.
Thread safety | ReadSafe |
---|---|
Category | Camera |
Loaded/Saved | false |
History 8
- 580 Change Default of MaxAxisFieldOfView from 70.0000076 to 70
- 553 Change Default of MaxAxisFieldOfView from to 70.0000076
- 486 Change ThreadSafety of MaxAxisFieldOfView from ReadOnly to ReadSafe
- 462 Change ThreadSafety of MaxAxisFieldOfView from to ReadOnly
- 452 Change Tags of MaxAxisFieldOfView from [] to [NotReplicated]
- 452 Change CanSave of MaxAxisFieldOfView from true to false
- 452 Change CanLoad of MaxAxisFieldOfView from true to false
- 450 Add MaxAxisFieldOfView
NearPlaneZ
Type | Default | |
---|---|---|
float | -0.5 |
The NearPlaneZ property describes how far away the camera's near clipping plane is, in studs. The near clipping plane is a geometric plane that sits in front of the camera's Camera.CFrame. Anything between this plane and the camera will not render, creating a cutaway view when viewing objects at very short distances. The value of NearPlaneZ varies across different platforms and is currently always between -0.1 and -0.5.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false/true |
History 4
- 553 Change Default of NearPlaneZ from to -0.5
- 486 Change ThreadSafety of NearPlaneZ from ReadOnly to ReadSafe
- 462 Change ThreadSafety of NearPlaneZ from to ReadOnly
- 327 Add NearPlaneZ
PanUnits
Parameters (1) | ||
---|---|---|
units | int | |
Returns (1) | ||
null |
This function pans the Camera around the Camera.Focus in 45 degree increments around the Y axis.
The rotation is applied to the camera's Camera.CFrame property.
This function pans the Camera in 45 degree increments, for example:
1 2 |
|
PanUnits does not require the Camera.CameraType to be 'Scriptable'.
Thread safety | Unsafe |
---|
ScreenPointToRay
Parameters (3) | Default | |
---|---|---|
x | float | |
y | float | |
depth | float | 0 |
Returns (1) | ||
Ray |
This function creates a unit Ray from a 2D position on the screen (defined in pixels), accounting for the GUI inset. The Ray originates from the Vector3 equivalent of the 2D position in the world at the given depth (in studs) away from the Camera.
As this function acknowledges the GUI inset, the offset applied to GUI elements (such as from the top bar) is accounted for. This means the screen position specified will start in the top left corner below the top bar. For an otherwise identical function that does not account for the GUI offset, use Camera:ViewportPointToRay().
As the Ray created is a unit ray, it is only one stud long. To create a longer ray, you can do the following:
1 2 3 4 |
|
This function only works for the current Workspace camera. Other cameras,
such as those you create for a ViewportFrame, have an initial
viewport size of (1, 1)
and are only updated after you set them to
Workspace.CurrentCamera. The mismatch in viewport size causes the
camera to return a ray with an incorrect Ray.Direction.
Thread safety | Safe |
---|
History 5
- 486 Change ThreadSafety of ScreenPointToRay from Unsafe to Safe
- 462 Change ThreadSafety of ScreenPointToRay from to Unsafe
- 189 Add ScreenPointToRay
- 188 Remove ScreenPointToRay
- 189 Add ScreenPointToRay
SetCameraPanMode
Parameters (1) | Default | |
---|---|---|
mode | CameraPanMode | Classic |
Returns (1) | ||
null |
This function sets the CameraPanMode to be used by the Camera on mobile devices.
When the *'EdgeBump' CameraPanMode is used, swipe to pan is disabled and the edge bump camera controls are enabled.
SetCameraPan mode has no effect on Windows or Mac users.
Thread safety | Unsafe |
---|
History 4
- 598 Change Tags of SetCameraPanMode from [] to [Deprecated]
- 573 Change ReturnType of SetCameraPanMode from void to null
- 462 Change ThreadSafety of SetCameraPanMode from to Unsafe
- 118 Add SetCameraPanMode
SetImageServerView
Parameters (1) | ||
---|---|---|
modelCoord | CFrame | |
Returns (1) | ||
null |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
History 3
- 573 Change ReturnType of SetImageServerView from void to null
- 462 Change ThreadSafety of SetImageServerView from to Unsafe
- 396 Add SetImageServerView
SetRoll
Parameters (1) | ||
---|---|---|
rollAngle | float | |
Returns (1) | ||
null |
This function is outdated and no longer considered best practice.
This function sets the current roll, in radians, of the Camera. The roll is applied after the Camera.CFrame and represents the rotation around the camera's Z-axis.
For example, the following would invert the Camera:
1
|
|
SetRoll has no effect on any roll applied using the Camera.CFrame property. Roll applied using SetRoll is not reflected in the Camera.CFrame property but is reflected in the CFrame returned byCamera:GetRenderCFrame().
This function can only be used when the Camera.CameraType is set to 'Scriptable', regardless of whether the default camera scripts are being used. If it is used with any other Camera.CameraType a warning is given in the output.
Any roll applied using this function will be lost when the Camera.CameraType is changed from 'Scriptable'.
To obtain the roll set using this function use Camera:GetRoll().
As this function is outdated, you are advised to instead apply roll to the Camera using the Camera.CFrame property. For example:
1 2 3 |
|
Thread safety | Unsafe |
---|
TiltUnits
Parameters (1) | ||
---|---|---|
units | int | |
Returns (1) | ||
bool |
This function 'tilts' the Camera by rotating it around the Camera.Focus around the camera's X axis by a given multiple of 10 degrees.
The rotation is applied to the camera's Camera.CFrame property and is constrained between -81.05 and 81.05 degrees.
This function tilts the Camera in 10 degree increments, for example:
1 2 |
|
TiltUnits does not require the Camera.CameraType to be 'Scriptable'.
See also:
Thread safety | Unsafe |
---|
VRTiltAndRollEnabled
Type | Default | |
---|---|---|
bool | false |
This property toggles whether to apply tilt and roll from the Camera.CFrame property while the player is using a VR device.
To prevent motion sickness, the horizon should remain level. Tilting and rolling the player's view while using a VR device can cause a disconnect between the player's physical space and the virtual space they are viewing. Changing the apparent downwards direction can cause players to lose balance or experience dizziness.
For these reasons, it is generally advisable to leave this property disabled, unless you have extensively tested your experience for these effects. Even with tilt and roll enabled, you may want to ensure the player always has a stable reference frame, such as the interior of a vehicle or a floor that can help the player ground themselves in their physical space.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true |
History 1
ViewportPointToRay
Parameters (3) | Default | |
---|---|---|
x | float | |
y | float | |
depth | float | 0 |
Returns (1) | ||
Ray |
This function creates a unit Ray from a 2D position on the viewport (defined in pixels). This position does not account for the GUI inset. The Ray originates from the Vector3 equivalent of the 2D position in the world at the given depth (in studs) away from the Camera.
As this function does not acknowledge the GUI inset, the viewport position given is not equivalent to the screen position used by GUI elements. If you are not using ScreenGui.IgnoreGuiInset and need an otherwise identical function that accounts for the GUI offset, use Camera:ScreenPointToRay().
This function can be used in conjunction with the Camera.ViewportSize property to create a ray from the centre of the screen, for example:
1 2 3 |
|
As the Ray created is a unit ray, it is only one stud long. To create a longer ray, you can do the following:
1 2 3 4 |
|
This function only works for the current Workspace camera. Other cameras,
such as those you create for a ViewportFrame, have an initial
viewport size of (1, 1)
and are only updated after you set them to
Workspace.CurrentCamera. The mismatch in viewport size causes the
camera to return a ray with an incorrect Ray.Direction.
Thread safety | Safe |
---|
History 3
- 486 Change ThreadSafety of ViewportPointToRay from Unsafe to Safe
- 462 Change ThreadSafety of ViewportPointToRay from to Unsafe
- 190 Add ViewportPointToRay
ViewportSize
Type | Default | |
---|---|---|
Vector2 | 1, 1 |
ViewportSize describes the dimensions, in pixels, of the client's viewport.
This property ignores the GUI inset applied by the top bar, meaning the center of the screen can be found at precisely at 50% of the viewport in both directions. You can find the position of a Vector3 in the world on the viewport using Camera:WorldToViewportPoint().
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false/true |
History 6
- 553 Change Default of ViewportSize from to Vector2(1, 1)
- 486 Change ThreadSafety of ViewportSize from ReadOnly to ReadSafe
- 462 Change ThreadSafety of ViewportSize from to ReadOnly
- 189 Add ViewportSize
- 188 Remove ViewportSize
- 189 Add ViewportSize
WorldToScreenPoint
Parameters (1) | ||
---|---|---|
worldPoint | Vector3 | |
Returns (1) | ||
Tuple |
This function returns the screen location and depth of a
Vector3 worldPoint
and whether this point is within the
bounds of the screen.
This function takes in account the current GUI inset, such as the space occupied by the top bar, meaning that the 2D position returned is in the same term as GUI positions and can be used to place GUI elements. For an otherwise identical function that ignores the GUI inset, see Camera:WorldToViewportPoint().
1 2 3 4 5 6 7 |
|
Note this function does not perform any raycasting and the boolean
indicating whether worldPoint
is within the bounds of the screen will be
true
regardless of whether the point is obscured by
BaseParts or Terrain.
Thread safety | Safe |
---|
History 5
- 486 Change ThreadSafety of WorldToScreenPoint from Unsafe to Safe
- 462 Change ThreadSafety of WorldToScreenPoint from to Unsafe
- 189 Add WorldToScreenPoint
- 188 Remove WorldToScreenPoint
- 189 Add WorldToScreenPoint
WorldToViewportPoint
Parameters (1) | ||
---|---|---|
worldPoint | Vector3 | |
Returns (1) | ||
Tuple |
This function returns the screen location and depth of a
Vector3 worldPoint
and whether this point is within the
bounds of the screen.
This function does not take in account the current GUI inset, such as the space occupied by the top bar, meaning that the 2D position returned is taken from the top left corner of the viewport. Unless you are using ScreenGui.IgnoreGuiInset, this position is not appropriate for placing GUI elements.
For an otherwise identical function that accounts for the GUI inset, see Camera:WorldToScreenPoint().
1 2 3 4 5 6 7 |
|
Note this function does not perform any raycasting and the boolean
indicating whether worldPoint
is within the bounds of the screen will be
true
regardless of whether the point is obscured by
BaseParts or Terrain.
Thread safety | Safe |
---|
History 3
- 486 Change ThreadSafety of WorldToViewportPoint from Unsafe to Safe
- 462 Change ThreadSafety of WorldToViewportPoint from to Unsafe
- 190 Add WorldToViewportPoint
Zoom
Parameters (1) | ||
---|---|---|
distance | float | |
Returns (1) | ||
bool |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
ZoomToExtents
Parameters (2) | ||
---|---|---|
boundingBoxCFrame | CFrame | |
boundingBoxSize | Vector3 | |
Returns (1) | ||
null |
Thread safety | Unsafe |
---|
History 2
- 573 Change ReturnType of ZoomToExtents from void to null
- 562 Add ZoomToExtents
focus
Type | Default | |
---|---|---|
CFrame |
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true/false |
Removed members 1
SetCameraInputMode
Parameters (1) | Default | |
---|---|---|
mode | CameraInputMode | Classic |
Returns (1) | ||
void |
Security | RobloxPlaceSecurity |
---|
History 2
- 118 Remove SetCameraInputMode
- 113 Add SetCameraInputMode