PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

Focus

Camera

CFrame

The Camera Focus is a DataType/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 PointLight|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’ Enum/RenderPriority.

Focus has no bearing on the positioning or orientation of the Camera (see Camera/CFrame|Camera.CFrame for this).


Code Samples


Following Camera

When the following code is placed inside a LocalScript named ‘CameraScript’ parented to StarterPlayerScripts|StarterPlayer.StarterPlayerScripts the default Roblox camera scripts are overwritten and replaced with a custom following camera.