Skip to content
Roblox API Reference

ViewportCamera

Memory category
Instances
Own members
0
Inherited members
118
Subclasses
0
Siblings
1

Properties44

Inherited fromObject2

Property categoryData

Inherited fromInstance21

Property categoryBehavior

Property categoryData

Property categoryPermissions

Inherited fromPVInstance2

Property categoryPivot

  • Editor-only property that displays and edits the pivot's CFrame relative to the instance, moving only the pivot and leaving the instance in place.
    • Not replicated
    • Not scriptable

Property categoryTransform

  • Editor-only property that reads and sets the world CFrame of the PVInstance's pivot, moving the entire instance when changed from the Studio Properties window.
    • Not replicated
    • Not scriptable
Inherited fromCamera19

Property categoryCamera

Property categoryData

  • Camera.CFrame: CFrame = CFrame.new(0, 20, 20, 1, 0, -0, -0, 0.707106829, 0.707106829, 0, -0.707106829, 0.707106829)
    The CFrame of the Camera, defining its position and orientation in the 3D world.
    • Capabilities: Basic
    • Simulation access
  • Camera.Focus: CFrame = CFrame.new(0, 0, -5, 1, 0, 0, 0, 1, 0, 0, 0, 1)
    Sets the area in 3D space that is prioritized by Roblox's graphical systems.
    • Capabilities: Basic
    • Simulation access
  • Toggles whether the camera will automatically track the head motion of a player using a VR device.
    • Capabilities: Basic
  • Sets the scale of the user's perspective of the world when using VR.
    • Capabilities: Basic
  • Describes the negative Z offset, in studs, of the camera's near clipping plane.
    • Read only
    • Capabilities: Basic
    • Save only
  • The dimensions of the device safe area on a Roblox client.
    • Read only
    • Capabilities: Basic
    • Save only
  • Toggles whether to apply tilt and roll from the CFrame property while the player is using a VR device.
    • Capabilities: Basic
  • Camera.CoordinateFrame: CFrame = CFrame.new(0, 20, 20, 1, 0, -0, -0, 0.707106829, 0.707106829, 0, -0.707106829, 0.707106829)
    Deprecated: This item has been superseded by Camera.CFrame which should be used in all new work.
    • Deprecated
    • Hidden
    • Not replicated
    • Capabilities: Basic
    • Load only
    • Simulation access

    Use CFrame instead.

  • Camera.focus: CFrame = CFrame.new(0, 0, -5, 1, 0, 0, 0, 1, 0, 0, 0, 1)
    Deprecated: This property is a deprecated variant of Focus which should be used instead.
    • Deprecated
    • Not replicated
    • Capabilities: Basic
    • Load only

    Use Focus instead.

Methods62

Inherited fromObject3
  • Get an event that fires when a given property of the object changes.
    Parameters
    ParameterDescription
    property: string
    The property to connect to.
    Returns
    TypeDescription
    RBXScriptSignal
    A signal that fires whenever the property changes.
  • Object:IsA(className: string): boolean
    Returns true if an object's class matches or inherits from a given class.
    • Custom Lua state
    • Thread safe
    Parameters
    ParameterDescription
    className: string
    The class against which the Object's class will be checked. Case-sensitive.
    Returns
    TypeDescription
    boolean
    Describes whether the Object's class matched or is a subclass of the given class.
  • Object:isA(className: string): boolean
    Deprecated: This deprecated function is a variant of Object:IsA() which should be used instead.
    • Deprecated
    • Custom Lua state
    Parameters
    Parameter
    className: string
    Returns
    Type
    boolean

    Use IsA instead.

Inherited fromInstance39
Inherited fromPVInstance2
Inherited fromCamera18
  • Returns an array of BaseParts that are obscuring the lines of sight between the camera's CFrame and the cast points.
    • Capabilities: Basic
    Parameters
    ParameterDescription
    castPoints: { any }
    An array of Vector3 positions of cast points.
    ignoreList: { Instance }
    An array of Instances that should be ignored, along with their descendants.
    Returns
    TypeDescription
    { Instance }
    An array of BaseParts that obscure the lines of sight between the camera's CFrame and the castPoints.
  • Returns the actual CFramewhere the Camera is being rendered, accounting for any roll applied and the impact of VR devices.
    • Capabilities: Basic
    Returns
    TypeDescription
    CFrame
    The CFrame the Camera is being rendered at.
  • Returns in radians the current roll, or rotation around the camera's Z-axis, applied to the Camera using SetRoll().
    • Capabilities: Basic
    Returns
    TypeDescription
    number
    The current roll applied by SetRoll(), in radians.
  • 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.
    • Thread safe
    • Capabilities: Basic
    Parameters
    ParameterDescription
    x: number
    The position on the X axis, in pixels, of the screen point at which to originate the Ray. This position accounts for the GUI inset.
    y: number
    The position on the Y axis, in pixels, of the screen point at which to originate the Ray. This position accounts for the GUI inset.
    depth: number? = 0
    The depth from the Camera, in studs, from which to offset the origin of the Ray.
    Returns
    TypeDescription
    Ray
    A unit Ray, originating from the equivalent Vector3 world position of the given screen coordinates at the given depth away from the Camera. This ray is orientated in the direction of the Camera.
    • Roblox script security
    • Capabilities: Basic
    Parameters
    Parameter
    modelCoord: CFrame
  • Camera:SetRoll(rollAngle: number)
    Sets the current rotation applied around the camera's Z-axis.
    • Capabilities: Basic
    Parameters
    ParameterDescription
    rollAngle: number
    The roll angle, in radians, to be applied to the Camera.
  • 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.
    • Thread safe
    • Capabilities: Basic
    Parameters
    ParameterDescription
    x: number
    The position on the X axis, in pixels, of the viewport point at which to originate the Ray, in device safe area coordinates.
    y: number
    The position on the Y axis, in pixels, of the viewport point at which to originate the Ray, in device safe area coordinates.
    depth: number? = 0
    The depth from the Camera, in studs, from which to offset the origin of the Ray.
    Returns
    TypeDescription
    Ray
    A unit Ray, originating from the equivalent Vector3 world position of the given viewport coordinates at the given depth away from the Camera. This ray is orientated in the direction of the Camera.
  • Returns the screen location and depth of a Vector3worldPoint and whether this point is within the bounds of the screen. Accounts for the GUI inset.
    • Thread safe
    • Capabilities: Basic
    Parameters
    ParameterDescription
    worldPoint: Vector3
    The Vector3 world position.
    Returns
    TypeDescription
    ...any
    A tuple containing, in order:
    • A Vector3 whose X and Y components represent the offset of the worldPoint from the top left corner of the screen, in pixels. The Vector3Z 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.
  • Returns the screen location and depth of a Vector3worldPoint and whether this point is within the bounds of the screen. Does not account for the GUI inset.
    • Thread safe
    • Capabilities: Basic
    Parameters
    ParameterDescription
    worldPoint: Vector3
    The Vector3 world position.
    Returns
    TypeDescription
    ...any
    A tuple containing, in order:
    • A Vector3 whose X and Y components represent the offset of the worldPoint from the top left corner of the viewport, in pixels for Workspace.CurrentCamera. For cameras inside a ViewportFrame, the values are normalized to [0, 1]. The Vector3Z 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.
    • Roblox script security
    • Capabilities: Basic
    Parameters
    Parameter
    distance: number
    Returns
    Type
    boolean
  • Camera:ZoomToExtents(boundingBoxCFrame: CFrame, boundingBoxSize: Vector3)
    Adjusts the CFrame so that the specified bounding box is fully visible within the camera's viewport.
    • Capabilities: Basic
    Parameters
    ParameterDescription
    boundingBoxCFrame: CFrame
    The CFrame representing the center and orientation of the bounding box to fit into the viewport.
    boundingBoxSize: Vector3
    The Vector3 size of the bounding box to fit into the viewport.
  • Deprecated: This method is deprecated. Do not use it for new work.
    Returns how much the Camera needs to be pushed towards its Focus in order to make sure there is no obstructions between the Focus and CFrame.
    • Deprecated
    • Capabilities: Basic
    Parameters
    ParameterDescription
    ignoreList: { Instance }
    An array of Instances to ignore. Descendants of these instances will also be ignored.
    Returns
    TypeDescription
    number
    The distance, in studs, that the Camera needs to be pushed towards its Focus to ensure there are no obstructions between the Focus and CFrame of the Camera.
  • 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.
    • Deprecated
    • Capabilities: Basic
    Returns
    TypeDescription
    number
    The speed at which the Camera is rotating around its Focus on the Y axis.
  • Deprecated: This method has been deprecated and no longer works.
    Returns the current tilt speed of the Camera.
    • Deprecated
    • Capabilities: Basic
    Returns
    TypeDescription
    number
    The speed at which the Camera is rotating around its Focus around the camera's X axis.
  • Camera:Interpolate(endPos: CFrame, endFocus: CFrame, duration: number)
    Deprecated: This method has been deprecated. Instead use TweenService to smoothly animate the Camera, see the code snippets below for an example.
    Tweens the Camera in a linear fashion towards a new CFrame and Focus over a given duration.
    • Deprecated
    • Capabilities: Basic
    Parameters
    ParameterDescription
    endPos: CFrame
    The CFrame for the Camera to tween to.
    endFocus: CFrame
    The CFrame for the camera's Focus to tween to.
    duration: number
    The duration, in seconds, of the tween.
  • Deprecated: This method was used for legacy camera controls and has since been deprecated. Do not use in new work.
    Pans the Camera around the Focus in 45 degree increments around the Y axis.
    • Deprecated
    • Capabilities: Basic
    Parameters
    ParameterDescription
    units: number
    The number of 45 degree increments by which to pan the Camera.
  • Deprecated: This method has been deprecated and should not be used in new work.
    Sets the CameraPanMode to be used by the Camera on mobile devices.
    • Deprecated
    • Capabilities: Basic
    Parameters
    ParameterDescription
    mode: Enum.CameraPanMode? = Enum.CameraPanMode.Classic
    The CameraPanMode to set the Camera to.
  • Deprecated: This method was used for legacy camera controls and has been deprecated. Do not use in new work.
    Tilts the Camera around its Focus in 10 degree increments around the camera's X axis.
    • Deprecated
    • Capabilities: Basic
    Parameters
    ParameterDescription
    units: number
    The number of 10 degree units by which to tilt the Camera.
    Returns
    TypeDescription
    boolean
    Whether the Camera tilt applied was constrained.

Events12

Inherited fromObject1
Inherited fromInstance9
Inherited fromCamera2