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. 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. As of the most recent versions of the game, the only way to access a client’s Camera object is through a LocalScript running on that client. Each client’s particular Camera object can be accessed through the CurrentCamera property of its local Workspace, assuming your code is running on that specific client.

A camera’s state is defined in the following way:

  • The Camera/CFrame property, represents the the position and orientation of the camera.
  • The Focus property represents the point the camera is looking at. It's important to set this property, 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 CameraScript will take care of this for you.
  • The CameraType property represents what action the game engine should perform on the Camera every frame.
  • The FieldOfView property, a number, represents the angle the user can see out the sides of the Camera.
  • An internal roll amount, which can be set by using the SetRoll method. This number (in radians) represents the angle in which the camera is rotated.
  • 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

    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

    Inherited from Instance: Show Hide

    int

    DataCost

    [ReadOnly] [NotReplicated]
    The cost of saving the instance using data persistence.
    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.
    string

    ClassName

    [ReadOnly] [NotReplicated]
    A read-only string representing the class this `Instance` belongs to.
    string

    Name

    A non-unique identifier of the `Instance`.
    bool

    Archivable

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

    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, it’s from the screen and whether it is visible or not. Does not account for the GUI inset

    Inherited from Instance: Show Hide

    RBXScriptSignal

    GetPropertyChangedSignal ( string property )

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

    FindFirstChildWhichIsA ( string className , bool recursive )

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

    GetDescendants ( )

    [CustomLuaState]
    Returns an array containing all of the `Instance`'s descendants.
    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.
    Instance

    FindFirstChildOfClass ( string className )

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

    FindFirstChild ( string name , bool recursive )

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

    FindFirstAncestorWhichIsA ( string className )

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

    FindFirstAncestorOfClass ( string className )

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

    FindFirstAncestor ( string name )

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

    IsA ( string className )

    Returns true if an `Instance`'s class matches or inherits from a given class
    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.
    string

    GetFullName ( )

    Returns a string showing the `Instance`'s ancestry.
    string

    GetDebugId ( int scopeLength )

    [NotBrowsable]
    Returns a coded string of the `Instance`s DebugId used internally by Roblox.
    Objects

    GetChildren ( )

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

    Destroy ( )

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

    Clone ( )

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

    ClearAllChildren ( )

    This function destroys all of an `Instance`'s children.

    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

    DescendantRemoving ( Instance descendant )

    Fires immediately before a descendant of the `Instance` is removed.
    RBXScriptSignal

    AncestryChanged ( Instance child , Instance parent )

    Fires when the `Instance/Parent` property of the object or one of its ancestors is changed.
    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

    Changed ( string property )

    Fired immediately after a property of an object changes.