We use cookies on this site to enhance your user experience

Camera

Camera

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

    Name Type Description
    CFrame

    Defines the CFrame of the Camera. The position component defines where the camera is, and the look vector defines where the camera is pointing.

    Instance

    A Model, Part, or Humanoid for the camera to look at.

    CameraType

    Specifies the Enum/CameraType of the Camera.

    float

    Sets the angle of the camera’s vertical field of view, between 1 and 120 degrees.

    CFrame

    Sets the area in 3D space that is prioritized by various graphical systems.

    bool

    Toggles whether the engine will automatically track the head motion of a player using a VR device. This should only be disabled when you are testing new VR mechanics. Unlinking the camera from a VR user’s head motions can cause motion sickness and should be avoided.

    float

    Sets the CFrame scale of the user’s head in VR.

    float

    The negative z-offset of the view frustum’s near clipping plane.

    Vector2

    The true size of the client’s viewport

    Inherited from Instance

    Archivable ClassName DataCost Name Parent RobloxLocked

    Functions

    Name Type Description
    float

    Returns how much the camera needs to be pushed forward in order to make sure there is no obstructions between the Camera/Focus and Camera/CFrame of the Camera.

    float

    Returns the camera’s current pan speed. [Broken]

    Objects

    Returns a list of BasePart that are obscuring the lines of sight between the castPoints, and the Camera’s Camera/CFrame. Parts that are specified in the ignoreList will not be included in the resulting array.

    CFrame

    Returns the actual CFrame of the Camera. This only makes a difference if the user is in VR mode.

    float

    Returns the camera’s current roll. Roll is defined in radians, and is stored as the delta from the camera’s y axis default normal vector.

    float

    Returns the camera’s current tilt speed.

    void

    Smoothly tweens the camera from the current coordinate frame to the supplied one with the given focus over the duration.

    void

    Pans the camera around the Camera/Focus in 45 degree increments.

    Ray

    Casts a Ray from the top-left corner of the pixel at (x, y), accounting for gui insets.

    void

    Changes the pan mode which is in use by the player’s camera.

    void

    The roll of the Camera, in radians. This sets how tilted the camera is on the Z-axis. Basically, this function “twists” the camera a specific amount.

    bool

    Tilts the Camera up and down around the Camera/Focus in 10 degree increments. The camera cannot be tilted higher or lower in total more than 90 degrees.

    Ray

    Same as ScreenPointToRay, except no GUI offsets are taken into account. Useful for things like casting a ray from the middle of the Camera.ViewportSize.

    Tuple

    Takes a 3D world point and returns information regarding its 2D screen location, its depth, and whether it is visible on the screen or not.

    Tuple

    Same as Camera/WorldToScreenPoint, except no GUI offsets are taken into account.

    Inherited from Instance

    ClearAllChildren Clone Destroy FindFirstAncestor FindFirstAncestorOfClass FindFirstAncestorWhichIsA FindFirstChild FindFirstChildOfClass FindFirstChildWhichIsA GetChildren GetDebugId GetDescendants GetFullName GetPropertyChangedSignal IsA IsAncestorOf IsDescendantOf WaitForChild

    Events

    Name Type Description

    Fires when the player’s camera moves between first and third person mode.

    Fired when the camera has finished interpolating.

    Inherited from Instance

    AncestryChanged Changed ChildAdded ChildRemoved DescendantAdded DescendantRemoving