Camera
The Camera object defines a view of the 3D game world.
Where the Camera object is found
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.
Each client's particular Camera object can be accessed through the Workspace.CurrentCamera property of the Workspace on that client.
Note, Workspace.CurrentCamera can also be used to find the Camera object in Roblox Studio.
How the Camera object works
The Camera's properties define the current view of the 3D game world. The most important of these being:
- The Camera.CFrame property represents the position and orientation of the camera.
- The Camera.Focus property represents the point the camera is looking at. It is important this property is set 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 camera scripts take care of this.
- The Camera.CameraType property is read by the game's camera scripts and determines how the Camera should update each frame.
- The Camera.CameraSubject property is read by the game's camera scripts and determines what object the Camera should follow.
- The Camera.FieldOfView property represents the extent of the observable world visible.
How to work with the Camera
Roblox's camera scripts update the Camera's properties every frame dependent on the current Camera.CameraType. This means developers looking to control the Camera themselves have two options.
- Setting the Camera.CameraType property to 'Scriptable'. When the Camera is in 'Scriptable' mode the default camera scripts will not update the camera. In most cases this is the easiest option.
- Replacing or modifying the default camera scripts in StarterPlayer.StarterPlayerScripts. This is only recommended for advanced developers.
Summary
Properties
Specifies the 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.
Toggles whether the Camera will automatically track the head motion of a player using a VR device.
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.
Describes the dimensions, in pixels, of the client's viewport.
Methods
Returns an array of BaseParts that are obscuring the lines of sight between the Camera's Camera.CFrame and the castPoints.
Returns in radians the current roll, or rotation around the Camera's Z-axis, applied to the Camera using Camera:SetRoll().
Returns the 2D screen location of a Vector3 position in the world, the depth of it from the screen and whether it is visible. Accounts for the GUI inset.
Returns the 2D screen location of a Vector3 position in the world, but does not account for the GUI inset.
Events
Fired when the Camera has finished interpolating usingCamera:Interpolate().
Properties
CFrame
This property is the CFrame of the Camera and defines its position and orientation in the 3D world.
Some transformations, such as the rotation of the head when using VR devices are not reflected in this property. For this reason, developers should use Camera:GetRenderCFrame() to obtain the 'true' CFrame of the camera.
How to set the camera's CFrame
You can move the camera by setting the CFrame property. However, the default camera scripts also set the CFrame property. When manually setting the CFrame property, it may be overwritten by the [camera scripts][1] which update every frame. There are two options to address this:
Set the camera Camera.CameraType to 'Scriptable'. When the camera is 'Scriptable' the default scripts will not update the CFrame. This method is simplest and recommended in most cases
Replace the default camera scripts with an alternative that doesn't interfere with the developer's desired implementation. This is only recommended when developers do not need any default camera's functionality
How the Camera CFrame works
Like all CFrame data, the camera CFrame represents a position and an orientation.
The most intuitive way to position and orientate the Camera is by using the CFrame.lookAt() constructor:
local pos = Vector3.new(0, 10, 0)local lookAtPos = Vector3.new(10, 0, 0)local cameraCFrame = CFrame.lookAt(pos, lookAtPos)workspace.CurrentCamera.CFrame = cameraCFrame
In the above example the Camera is positioned at Vector3.new(0, 10, 0) and oriented to be looking towards Vector3.new(10, 0, 0).
Animating the Camera CFrame
Although the camera can be placed in the manner demonstrated above, you may want to animate the Camera to smoothly move from one CFrame to another. For this, there are a number of options:
- Creating a Tween using TweenService that animates the CFrame property of the camera. See the code sample below for an example of this
- Setting the camera CFrame every frame with RunService:BindToRenderStep() and the lerp CFrame method
Code Samples
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local camera = workspace.CurrentCamera
function playCutscene(character)
local primaryPart = character.PrimaryPart
camera.CameraType = Enum.CameraType.Scriptable
local baseCFrame = primaryPart.CFrame * CFrame.new(0, 0, -100) * CFrame.Angles(0, math.pi, 0)
local targetCFrame = primaryPart.CFrame * CFrame.new(0, 0, -10) * CFrame.Angles(0, math.pi, 0)
camera.CFrame = baseCFrame
local tween = TweenService:Create(camera, TweenInfo.new(2), { CFrame = targetCFrame })
tween:Play()
tween.Completed:Wait()
camera.CameraType = Enum.CameraType.Custom
end
localPlayer.CharacterAdded:Connect(function(character)
task.wait(3)
playCutscene(character)
end)
CameraSubject
When using the default camera scripts, the CameraSubject property has two roles:
- Defining the object the Camera is to follow, in the case of the 'Follow', 'Attach', 'Track', 'Watch' and 'Custom' CameraTypes
- For all CameraTypes but 'Scriptable', the object whose position the Camera's Camera.Focus will be set to
CameraSubject accepts a variety of Instances. The default camera scripts respond differently to different CameraSubject types:
- Humanoid: By default the CameraSubject is set to the LocalPlayer's Humanoid. The camera scripts will follow the Humanoid factoring in the Humanoid's current state and Humanoid.CameraOffset
- BasePart: The camera scripts will follow the position of any BasePart, with a vertical offset in the case of VehicleSeats
You can configure the Camera to follow a Model by setting the CameraSubject to the model's Model.PrimaryPart.
The CameraSubject cannot be set to nil. If it is, it will revert to its previous value.
To restore the CameraSubject to its default value, set it to the LocalPlayer's Humanoid like so:
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local function resetCameraSubject()
if workspace.CurrentCamera and localPlayer.Character then
local humanoid = localPlayer.Character:FindFirstChildOfClass("Humanoid")
if humanoid then
workspace.CurrentCamera.CameraSubject = humanoid
end
end
end
CameraType
The default Roblox camera scripts have several built in behaviors. Setting the CameraType of a player's Camera will toggle between these behaviors. Note some CameraType's require a valid Camera.CameraSubject to work correctly.
- Fixed: Camera is stationary
- Follow: Camera moves with the Camera.CameraSubject and rotates to keep the subject in the center of view
- Attach: Camera moves with the Camera.CameraSubject at a fixed offset and will rotate as the subject rotates
- Track: Camera moves with the Camera.CameraSubject but does not rotate automatically
- Watch: Camera is stationary but will rotate to keep the Camera.CameraSubject in the center of view
- Custom: Default
- Scriptable: No default behavior. Used by developers to script custom behavior
The above only applies when you use the default Roblox [camera scripts][1]. If you write your own camera scripts, you can choose to listen to CameraType and implement your own behaviors or ignore the property entirely.
Manually controlling the Camera
In some cases you may wish to manually control the Camera (for example during a cut-scene). The best way to do this is by setting the CameraType to 'Scriptable'. The default camera scripts will not move or update the Camera on its own if CameraType is set to 'Scriptable'. This means you can freely modify the Camera using its properties and functions. For more information on positioning and orientating the Camera manually see the Camera.CFrame page.
If you want complete control over the camera at all times, you may replace the default camera scripts with your own.
Code Samples
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local camera = workspace.CurrentCamera
function playCutscene(character)
local primaryPart = character.PrimaryPart
camera.CameraType = Enum.CameraType.Scriptable
local baseCFrame = primaryPart.CFrame * CFrame.new(0, 0, -100) * CFrame.Angles(0, math.pi, 0)
local targetCFrame = primaryPart.CFrame * CFrame.new(0, 0, -10) * CFrame.Angles(0, math.pi, 0)
camera.CFrame = baseCFrame
local tween = TweenService:Create(camera, TweenInfo.new(2), { CFrame = targetCFrame })
tween:Play()
tween.Completed:Wait()
camera.CameraType = Enum.CameraType.Custom
end
localPlayer.CharacterAdded:Connect(function(character)
task.wait(3)
playCutscene(character)
end)
DiagonalFieldOfView
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 FOV.
FieldOfView
Field of view, often shortened to FOV, is the extent of the observable game world that can be seen on screen at a given moment. The FieldOfView 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.
The FieldOfView property sets how many degrees in the vertical direction (y-axis) the camera can view. Uniform scaling is enforced meaning the vertical and horizontal field of view are always related by the aspect ratio of the screen. This means the FieldOfView property also determines the horizontal field of view.
See the images below for an example of how different FieldOfView settings can impact the extent of the perceptive game world. At a FOV of 70, a considerable portion of the game world is visible:
However when the FOV is reduced to 30, although the Camera's Camera.CFrame has not changed, a much smaller portion of the game world is rendered:
Suggested uses for FieldOfView
Changing FOV can produce a variety of effects, such as:
- 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
FieldOfViewMode
The Camera's FOV must be updated to reflect ViewportSize changes. The value of the FieldOfViewMode property determines which FOV value will be kept constant.
For example, when the value of FieldOfViewMode is set to FieldOfViewMode.Vertical, the horizontal FOV is updated when the viewport is resized, while the vertical FOV is kept constant. On the other hand, if the value is set to FieldOfViewMode.Diagonal, both horizontal and vertical FOV might be changed to keep the diagonal FOV constant.
Focus
The Camera Focus is a CFrame that determines the area in 3D space the graphics engine will prioritize.
Certain graphical operations Roblox performs, such as updating lighting, can take a lot of time or computational effort to complete. Focus tells Roblox the 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 the Focus to follow the Camera.CameraSubject (usually a Humanoid). However, Focus will not be automatically updated in the following cases:
- When the Camera.CameraType is set to 'Scriptable'
- When the default camera scripts are not being used
In these cases, you should update Focus every frame, using RunService:BindToRenderStep() function at the 'Camera' RenderPriority.
Focus has no bearing on the positioning or orientation of the Camera (see Camera.CFrame for this).
Code Samples
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local OFFSET = Vector3.new(20, 20, 20)
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
-- Detatch the character's rotation from the camera
UserSettings().GameSettings.RotationType = Enum.RotationType.MovementRelative
local function onRenderStep()
local character = player.Character
if character then
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if humanoidRootPart then
-- Update the position of the camera
local playerPosition = humanoidRootPart.Position
local cameraPosition = playerPosition + OFFSET
camera.CFrame = CFrame.new(cameraPosition, playerPosition)
-- Update the focus of the camera to follow the character
camera.Focus = humanoidRootPart.CFrame
end
end
end
RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)
HeadLocked
Un-linking the camera from a VR user's head motions can cause motion sickness. This property should only be set to false after extensive testing.
Toggles whether the Camera will automatically track the head motion of a player using a VR device.
When HeadLocked is true, the engine will combine 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:
local UserInputService = game:GetService("UserInputService")local headCFrame = UserInputService:GetUserCFrame(Enum.UserCFrame.Head)headCFrame = headCFrame.Rotation + headCFrame.Position * workspace.CurrentCamera.HeadScale-- this will be equivalent to Camera:GetRenderCFrame()local renderCFrame = workspace.CurrentCamera.CFrame * headCFrame
Disabling HeadLocked
You are recommended not to disable HeadLocked 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's 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 Camera.CFrame combined with the CFrame of the user's head
HeadScale
HeadScale is the scale of the user's perspective of the world when using VR.
The size of a stud in VR is:
1 stud = 0.3 meters / HeadScale
This means the larger the HeadScale value, the smaller the world will look from the user's perspective when using VR devices and vice versa. For example, a part that is 1 stud tall appears to be 0.6 meters tall to a VR player with a HeadScale = 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 = VRScaling.Off.
When not using VR, this property has no effect.
This property should not be confused with Humanoid HeadScale, which is a NumberValue parented to a Humanoid to control its scaling.
See also:
The following are also useful when developing for VR:
MaxAxisFieldOfView
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 FOV of the Camera.
See FieldOfView for a more general explanation of FOV.
NearPlaneZ
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. This creates a cutaway view when viewing objects at very short distances. See the images below for a visual example of this:
The value of NearPlaneZ varies across different platforms, but is currently always between -0.1 and -0.5.
- Most windows systems, all Xbox systems and most iOS systems support the more precise value of -0.1
- Currently Mac and Android systems only support a NearPlaneZ of -0.5, although this may change in the future
VRTiltAndRollEnabled
ViewportSize
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 ViewportSize in both directions
- You can find the position of a Vector3 in the world on the viewport using Camera:WorldToViewportPoint()
Methods
GetPartsObscuringTarget
This function returns an array of BaseParts that are obscuring the lines of sight between Camera's Camera.CFrame and the castPoints.
GetPartsObscuringTarget is used by the 'Invisicam' in the default camera scripts to hide parts between the Camera's Camera.CFrame and Camera.Focus.
Any Instances included in the ignoreList array will, along with their descendants, be ignored.
See below for a visual example of this function. The Camera is represented by the grey camera model and the cast points are represented by the colored dots. The Parts highlighted in red are the ones that would be returned.
The castPoints parameter is given as an array of Vector3s, for example:
local castPoints = {Vector3.new(0, 10, 0), Vector3.new(0, 15, 0)}local ignoreList = {}workspace.CurrentCamera:GetPartsObscuringTarget(castPoints, ignoreList)
The array of BaseParts returned is in an arbitrary order, and no additional raycast data is provided (for example hit position, hit material and surface normal). If this information is required, you should a Workspace raycast function such as Workspace.FindPartOnRayWithIgnoreList.
If Terrain obscures a cast point, BaseParts obscuring the cast point between the obscuring Terrain and the cast point will not be returned.
Note, this function benefits from internal optimisations that make it more performant than casting a ray for each cast point individually.
Parameters
Returns
An array of BaseParts that obscure the lines of sight between the Camera's Camera.CFrame and the castPoints.
Code Samples
local function XRay(castPoints, ignoreList)
ignoreList = ignoreList or {}
local parts = workspace.CurrentCamera:GetPartsObscuringTarget(castPoints, ignoreList)
for _, part in pairs(parts) do
part.LocalTransparencyModifier = 0.75
for _, child in pairs(part:GetChildren()) do
if child:IsA("Decal") or child:IsA("Texture") then
child.LocalTransparencyModifier = 0.75
end
end
end
end
XRay({ Vector3.new() })
GetRenderCFrame
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. For this reason, 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:
local UserInputService = game:GetService("UserInputService")local headCFrame = UserInputService:GetUserCFrame(Enum.UserCFrame.Head)headCFrame = headCFrame.Rotation + headCFrame.Position * workspace.CurrentCamera.HeadScalerenderCFrame = workspace.CurrentCamera.CFrame * headCFrame
The Camera's render CFrame will only be changed to account for the head when the Camera.HeadLocked property is true.
Returns
GetRoll
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:
local function getActualRoll()
local camera = workspace.CurrentCamera
local trueUp = Vector3.new(0, 1, 0)
local cameraUp = camera:GetRenderCFrame().upVector
return math.acos(trueUp:Dot(cameraUp))
end
Returns
The current roll applied by Camera:SetRoll(), in radians.
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
ScreenPointToRay
This function creates a unit Ray from a 2D position on the screen (defined in pixels). This position accounts 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 accounts for 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:
local camera = workspace.CurrentCameralocal length = 500local unitRay = camera:ScreenPointToRay(100, 100)local ray = Ray.new(unitRay.Origin, unitRay.Direction * length)
Parameters
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.
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.
Returns
Code Samples
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local camera = workspace.CurrentCamera
--This will create a cube facing centered at the origin of the [[Ray]] returned and facing in the same direction. The center of the cube will be one stud in front of the camera.
mouse.Button1Down:Connect(function()
local ray = camera:ScreenPointToRay(mouse.X, mouse.Y, 1)
local cube = Instance.new("Part")
cube.Size = Vector3.new(1, 1, 1)
cube.CFrame = CFrame.new(ray.Origin, ray.Origin + ray.Direction)
cube.Anchored = true
cube.Parent = workspace
end)
SetRoll
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:
workspace.CurrentCamera:SetRoll(math.pi) -- math.pi radians = 180 degrees
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:
local currentCFrame = workspace.CurrentCamera.CFramelocal rollCFrame = CFrame.Angles(0, 0, roll)workspace.CurrentCamera.CFrame = currentCFrame * rollCFrame
Parameters
Returns
ViewportPointToRay
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 account for 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:
local camera = workspace.CurrentCameralocal viewportPoint = camera.ViewportSize / 2local unitRay = camera:ViewportPointToRay(viewportPoint.X, viewportPoint.Y, 0)
As the Ray created is a unit ray it is only one stud long. To create a longer ray, you can do the following:
local camera = workspace.CurrentCameralocal length = 500local unitRay = camera:ScreenPointToRay(100, 100)local ray = Ray.new(unitRay.Origin, unitRay.Direction * length)
Parameters
The position on the X axis, in pixels, of the viewport point at which to originate the Ray. This position does not account for the GUI inset.
The position on the Y axis, in pixels, of the viewport point at which to originate the Ray. This position does not account for the GUI inset.
Returns
WorldToScreenPoint
This function returns the screen location and depth of a Vector3 worldPoint and whether this point is visible on the screen or not.
This function takes in account the current GUI inset (such as the space occupied by the top bar). This means 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().
For example:
local camera = workspace.CurrentCameralocal worldPoint = Vector3.new(0, 10, 0)local vector, onScreen = camera:WorldToScreenPoint(worldPoint)local screenPoint = Vector2.new(vector.X, vector.Y)local depth = vector.Z
Note this function does not perform any raycasting, meaning the visible bool will be true regardless if the worldPoint is obscured by BaseParts or Terrain.
Parameters
Returns
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 Vector3's Z component represents the depth of the worldPoint from the screen (in studs).
A bool indicating if the worldPoint is within the bounds of the screen
WorldToViewportPoint
This function returns the screen location and depth of a Vector3 worldPoint and whether this point is visible on the screen or not.
This function does not take in account the current GUI inset (such as the space occupied by the top bar). This means the 2D position returned is taken from the top left corner of the viewport. This means, 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().
For example:
local camera = workspace.CurrentCameralocal worldPoint = Vector3.new(0, 10, 0)local vector, inViewport = camera:WorldToViewportPoint(worldPoint)local viewportPoint = Vector2.new(vector.X, vector.Y)local depth = vector.Z
Note this function does not perform any raycasting, meaning the visible bool will be true regardless if the worldPoint is obscured by BaseParts or Terrain.
Parameters
Returns
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. The Vector3's Z component represents the depth of the worldPoint from the screen (in studs).
A bool indicating if the worldPoint is within the bounds of the viewport.
Code Samples
local function isPointVisible(worldPoint)
local camera = workspace.CurrentCamera
local _, onScreen = camera:WorldToViewportPoint(worldPoint)
if onScreen then
local origin = camera.CFrame.p
local ray = Ray.new(origin, worldPoint - origin)
local hit = workspace:FindPartOnRay(ray)
if hit then
return false
end
else
return false
end
return true
end
print(isPointVisible(Vector3.new(20, 0, 0)))
Events
InterpolationFinished
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.