Hi so im making a custom camera for irreleveant things and its working almost perfectly fine other than minute details, but currently im having issues with the camera stuttering.
The important code that uses RunService to update the Camera :
RunService:BindToRenderStep("CameraUpdate", Enum.RenderPriority.Camera.Value + 3, function(dt)
UpdateCamera(dt)
end)
I’ve tried normal RenderStepped, stepped, blah blah, all give the same results.
The function UpdateCamera() :
function UpdateCamera(dt)
local MouseDelta = UserInputService:GetMouseDelta() * dt
xAngle = (xAngle - MouseDelta.X * Sensitivity)
yAngle = math.clamp((yAngle - MouseDelta.Y * Sensitivity), -80, 80)
local StartCFrame = CFrame.new(HumanoidRootPart.Position + Vector3.new(0,2,0)) * CFrame.Angles(0, math.rad(xAngle), 0) * CFrame.Angles(math.rad(yAngle), 0, 0)
local CameraCFrame = StartCFrame + StartCFrame:VectorToWorldSpace(Vector3.new(CameraOffset.X,CameraOffset.Y,CameraOffset.Z))
local CameraFocus = StartCFrame + StartCFrame:VectorToWorldSpace(Vector3.new(CameraOffset.X,CameraOffset.Y,-50000))
FinalFrame = CFrame.new(CameraCFrame.Position, CameraFocus.Position)
-- See more [UpdateCode]
end
Now if i use this code for [UpdateCode]
CurrentCamera.CFrame = FinalFrame
There is absoultley no stuttering, but i want my camera to lag behidn the character so i resorted to using TweenService, and also CFrame:Lerp using a hardCoded WaitTime variable * dt
TweenService:Create(CurrentCamera, TweenInfo.new(
WaitTime * dt, Enum.EasingStyle.Sine),
{
CFrame = FinalFrame
}):Play()
CurrentCamera.CFrame = CurrentCamera.CFrame:Lerp(FinalFrame, 1/WaitTime * dt)
and All of them except straight up setting the cframe to the final frame result in a stutter shown here