Type Index Pages
- BillboardGui
- CanvasGroup
- Frame
- Hint
- ImageButton
- ImageLabel
- PlayerGui
- ScreenGui
- ScrollingFrame
- StarterGui
- SurfaceGui
- TextBox
- TextButton
- TextLabel
- UIAspectRatioConstraint
- UIGradient
- UIGridLayout
- UIListLayout
- UIPadding
- UIPageLayout
- UIScale
- UISizeConstraint
- UITableLayout
- UITextSizeConstraint
- VideoFrame
- ViewportFrame
- ChangeHistoryService
- CoreGui
- DataModelSession
- DockWidgetPluginGui
- MultipleDocumentInterfaceInstance
- Plugin
- PluginAction
- PluginGui
- PluginGuiService
- PluginManager
- PluginMenu
- PluginMouse
- PluginToolbar
- PluginToolbarButton
- QWidgetPluginGui
- Selection
- StandalonePluginScripts
- StatsItem
- StudioService
- StudioTheme
No results found!
-
Instance
- GameSettings
- DebugSettings
- BodyMover
- WeldConstraint
- HttpRbxApiService
- NotificationService
- Translator
- Lighting
- Beam
- GuiService
- UserInputService
- Studio
- Plugin
- HttpService
- Mouse
- BindableEvent
- RunService
- Pages
- Humanoid
- TestService
- PathfindingService
- Chat
- NetworkPeer
- Feature
- CharacterAppearance
- Constraint
- NetworkReplicator
- JointInstance
- Light
- BasePlayerGui
- AnalyticsService
- NetworkMarker
- BinaryStringValue
- FlyweightService
- Geometry
- LoginService
- InstancePacketCache
- ThirdPartyUserService
- TouchInputService
- RuntimeScriptService
- GuidRegistryService
- PartOperationAsset
- DialogChoice
- PhysicsService
- AdService
- TextService
- MarketplaceService
- TeleportService
- Accoutrement
- GamePassService
- AssetService
- InsertService
- PointsService
- ChangeHistoryService
- ServerScriptService
- JointsService
- LogService
- InputObject
- Toolbar
- LuaSettings
- RenderSettings
- AnimationTrack
- PhysicsSettings
- NetworkSettings
- CFrameValue
- Animation
- Color3Value
- BoolValue
- BrickColorValue
- Vector3Value
- AnimationController
- BindableFunction
- Button
- Trail
- LocalizationTable
- LocalizationService
- DebuggerBreakpoint
- DebuggerWatch
- ScriptDebugger
- Animator
- Attachment
- RemoteFunction
- RemoteEvent
- PluginManager
- Camera
- Stats
- Sky
- StarterPlayer
- Dragger
- TerrainRegion
- Path
- TextFilterResult
- Dialog
- StatsItem
- GoogleAnalyticsConfiguration
- ScriptContext
- ControllerService
- CacheableContentProvider
- ReflectionMetadataClasses
- ReflectionMetadataEnums
- DebuggerManager
- GuiBase
- UIBase
- LuaSourceContainer
- GuiItem
- DataModelMesh
- ServiceProvider
- ReflectionMetadataItem
- PostEffect
- PhysicsPacketCache
- TouchTransmitter
- RobloxReplicatedStorage
- Visit
- LuaWebService
- ScriptService
- FlagStandService
- VirtualUser
- SpawnerService
- TimerService
- CookiesService
- Team
- GroupService
- StarterGear
- Message
- PlayerScripts
- Configuration
- ContentProvider
- CollectionService
- Debris
- ReplicatedFirst
- ServerStorage
- ReplicatedStorage
- Folder
- TweenService
- Players
- ContextActionService
- StarterPlayerScripts
- SoundService
- KeyframeSequenceProvider
- VRService
- PluginGuiService
- Player
- Teams
- Pose
- Keyframe
- KeyframeSequence
- IntConstrainedValue
- DoubleConstrainedValue
- ForceField
- RayValue
- Fire
- Smoke
- Sparkles
- ParticleEmitter
- IntValue
- StringValue
- NumberValue
- Explosion
- ObjectValue
- SoundGroup
- UserGameSettings
- ClickDetector
- Sound
- Selection
- BadgeService
- TaskScheduler
- GlobalDataStore
- DataStoreService
- CustomEvent
- CustomEventReceiver
- VirtualInputManager
- FunctionalTest
- TweenBase
- SoundEffect
- ReflectionMetadataEvents
- ClusterPacketCache
- PVInstance
- FaceInstance
- Controller
- ReflectionMetadataCallbacks
- ReflectionMetadataFunctions
- ReflectionMetadataYieldFunctions
- ReflectionMetadataProperties
- ReflectionMetadata
- AdvancedDragger
- HapticService
- FriendService
- GamepadService
No Result Found !!!
CFrame
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
Like all 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
TweenusingTweenServicethat 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
Code Samples
Basic Camera Cutscene
In this code sample a simple Camera animation is played after the Players/LocalPlayer spawns using TweenService. The Camera/CameraType of the Camera is set to ‘Scriptable’ so the default camera scripts do not interfere.
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)
wait(3)
playCutscene(game.Players.LocalPlayer.Character)
end)
How this site use cookies
This Platform uses cookies to offer you a better experience, to personalize content, to provide social media features and to analyse the traffic on our site. For further information, including information on how to prevent or manage the use of cookies on this Platform, please refer to our Privacy and Cookie Policy.