I want to make the Camera follow the character Smoothly
The problem is, when player is going in high speeds, the character or the camera starts glitching. (Jittery movement)
I haven’t found any help on dev forum.
This is my Local Script:
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local camera:Camera = workspace.CurrentCamera
local targetPos = nil
local smoothness = 0.06
local followDistance = 10
local verticalOffset = Vector3.new(0, 2, 0)
RunService:BindToRenderStep("SmoothFlightCam", Enum.RenderPriority.Camera.Value, function()
local char = player.Character
if not char then return end
if char:GetAttribute("fly") == false then
return
end
camera.CameraType = Enum.CameraType.Custom
local hrp = char:FindFirstChild("HumanoidRootPart")
if not hrp then return end
local desiredCenterPos = hrp.Position + verticalOffset
if not targetPos then
targetPos = desiredCenterPos
end
targetPos = targetPos:Lerp(desiredCenterPos, smoothness)
local lookDir = camera.CFrame.LookVector
local camPos = targetPos - lookDir * followDistance
--camera.CFrame = CFrame.new(camPos)
camera.CFrame = CFrame.lookAt(camPos, targetPos)
end)