I wanted to make a camera animation, but I decided to take a more "unorthodox" method to say the least. Instead of using TweenService
to animate the camera itself, I decided to animate a Humanoid
's torso using Moon Animator because it would be easier for me to control the timing of the camera and I wouldn't have to worry about making +20 Tweens with different timing, after exporting the animation I would insert a LocalScript
inside StarterPlayerScripts
that would update the CFrame
of the camera accordingly to the CFrame
to the torso, this is the script I came up with:
local RunService = game:GetService("RunService") workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable local function onRenderStepUpdate(deltaTime) local Humanoid = workspace:WaitForChild("Humanoid") local Torso = Humanoid.Torso local ToPosition = Torso.CFrame.Position local ToOrientation = Torso.CFrame.LookVector local CamPosition = workspace.CurrentCamera.CFrame.Position local CamOrientation = workspace.CurrentCamera.CFrame.LookVector CamPosition = Vector3.new(ToPosition.X, ToPosition.Y, ToPosition.Z) CamOrientation = Vector3.new(ToOrientation.X, ToOrientation.Y, ToOrientation.Z) print("Camera Update") end RunService.RenderStepped:Connect(onRenderStepUpdate) -- I used RenderStepped since camera manipulation displays immediate feedback to the player.
The script doesn't work and there are no errors in the output, it prints "Camera Update" but doesn't actually move the camera in any way, the player is still able to move the camera as if the CameraType
was "Custom" and not "Scriptable".
I know it is a cheap way of animating the camera but that's more comfortable to me and it allows me to have more control on the animation, I honestly don't know what's the issue here but if you do please let me know.
I didn't quite understand your question but, if you are making a cutscene and trying to animate the camera, then I suggest not making the campart a humanoid, I personally make my camera a model, I put the camerapart, a rootpart to rig the camera and a torso because I don't know, then i use moon animator for the animating(of course) and i start to animate.
Problem
You are trying to set the Camera's position & orientation but it is not working. This is because you are never setting the camera's CFrame. You are instead setting the values of variables to new vector3 values.
Solution
Make proper assignments to the Camera's CFrame, and ensure that the Camera's type is Scriptable.
Code
-- Set Camera type camera.CameraType = "Scriptable" local ToPosition = Torso.CFrame.Position local ToOrientation = Torso.CFrame.LookVector -- The two lines below are commented out as they are not needed. --local CamPosition = workspace.CurrentCamera.CFrame.Position --local CamOrientation = workspace.CurrentCamera.CFrame.LookVector workspace.CurrentCamera.CFrame = CFrame.lookAt(ToPosition, ToOrientation) -- The two lines below are commented out as they are not needed. --CamPosition = Vector3.new(ToPosition.X, ToPosition.Y, ToPosition.Z) --CamOrientation = Vector3.new(ToOrientation.X, ToOrientation.Y, ToOrientation.Z)
Notes
You should use CFrame.lookAt instead of the old constructor:
Old Constructor:
New Method that should be used:
CFrame.lookAt ( Vector3 at, Vector3 lookAt, Vector3 up = Vector3.new(0, 1, 0) )
The 'at' argument is the position of the CFrame. The second argument 'lookAt' is the direction the CFrame is facing (ie. the direction the camera is facing). The last argument (up) is not generally required; it is optional.
Conclusion
If you have any more questions, or anything about this answer confuses you, feel free to contact me via Discord
(phxntxsmic#2021)
. Make sure to give some context if you contact me to make it easier.
Edit 1: Fixed Discord tag