The camera is not the one jittering, it’s the character itself. Tested it with someone and I could clearly see their jitter as well.
Here is part of the code that handles updating:
function cameraModule:UpdateCamera(dt)
local camera_cframe = CFrame.new()
for i = 1, #instances do
camera_cframe *= instances[i](dt)
end
return camera_cframe
end
function cameraModule:StartCamera()
RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, function(dt)
camera.CFrame = self:UpdateCamera(dt)
end)
end
Solving it:
local function Lerp(a, b, t)
return a + (b - a) * t
end
local function Solve()
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
local rootX = root.Position.X
local rootY = root.Position.Y
local rootZ = root.Position.Z
rootX = Lerp(px, rootX, .2)
rootY = Lerp(py, rootY, .2)
rootZ = Lerp(pz, rootZ, .2)
local ch = math.cos(angleX)
local sh = math.sin(angleX)
local cb = math.cos(angleY)
local sb = math.sin(angleY)
local m12 = sh*sb
local m13 = sh*cb
local m32 = ch*sb
local m33 = ch*cb
local local_x = ch*2 + m12*2 + m13*14 + rootX
local local_y = cb*2 + -sb*14 + rootY
local local_z = -sh*2 + m32*2 + m33*14 + rootZ
px = rootX
py = rootY
pz = rootZ
local result = workspace:Raycast(
Vector3.new(rootX, rootY, rootZ),
Vector3.new(local_x - rootX, local_y - rootY, local_z - rootZ),
raycast
)
if result then
return CFrame.new(
local_x + .1, local_y + .1, local_z + .1,
ch, m12, m13,
0, cb, -sb,
-sh, m32, m33
)
else
return CFrame.new(
local_x + .1, local_y + .1, local_z + .1,
ch, m12, m13,
0, cb, -sb,
-sh, m32, m33
)
end
end
Something to note is that it also jitters when I remove lerp and/or when I switch it to CFrame.