This property is the
DataType/CFrame of the
Camera and definies 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’
DataType/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 which update every frame. There are two options to address this:
Set the camera
Camera/CameraTypeto ‘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
DataType/CFrame|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 new CFrame constructor with the pos and lookAt parameters, for example:
local pos = Vector3.new(0, 10, 0) local lookAt = Vector3.new(10, 0, 0) local cameraCFrame = CFrame.new(pos, lookAt) 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
TweenServicethat 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/BindToRenderStepand the lerp CFrame method
Basic Camera Cutscene
In this code sample a simple
Camera animation is played after the
Players/LocalPlayer spawns using
Camera/CameraType of the
Camera is set to ‘Scriptable’ so the default camera scripts do not interfere.