Camera Delay Jitter

I am trying to create a Camera Delay Effect when using this trolley, here is how I do it

-- Variables
local Player = game.Players.LocalPlayer
local Camera = workspace.CurrentCamera

return function(subject:BasePart,angle:CFrame)
	print("Follow")
	local Character = Player.Character
		local Humanoid:Humanoid = Character:FindFirstChild("Humanoid")
	
	local offset = Vector3.zero
	local lookVector = subject.CFrame.LookVector
	local rightVector = subject.CFrame.RightVector
	
	offset += rightVector*Humanoid.CameraOffset.X -- Left/Right
	offset += Vector3.yAxis*Humanoid.CameraOffset.Y -- Up/Down
	offset += lookVector*Humanoid.CameraOffset.Z -- Forward/Backward
	
	local pos = Camera.CFrame.Position:Lerp(subject.Position+offset,.2)
	
	return CFrame.new(pos)*angle
end

It works fine, but the problem is the camera jitters, how do I fix this? I’ve read this post but it doesnt work for me Camera Delay effect - jiggle issue - #40 by BendsSpace
Any help?

1 Like

Cant you just make a closure?
Indexing instance every frame is straight up insane.
Also im pretty sure its more of a problem as to you binding it to a wrong event in runservice.

What do you mean by that?
eeeee

How about using PreRender as the camera update timing?

Try using BindToRenderStep instead of connecting to any runservice events, and try to mess with the second parameter (the priority), try setting the priority value to Enum.RenderPriority.Camera.Value + 1 and see if that works. If it doesn’t, try lerping the cframe of the camera along with your additional offsets so the jitter is smoothened out and not visible.

I am already using BindToRenderStep and fiddling with the priority doesnt work

local function update()
	if not Player.Character then return end
	
	local Character = Player.Character
		local Humanoid:Humanoid = Character:FindFirstChild("Humanoid")
		local HumanoidRootPart:BasePart = Character:FindFirstChild("HumanoidRootPart")
	
	if Humanoid:GetAttribute("Ragdoll") then
		local pos = HumanoidRootPart.Position+Vector3.new(0,10,0)
		local cf = CFrame.lookAt(pos,HumanoidRootPart.Position)

		Camera.CFrame = Camera.CFrame:Lerp(cf,.05)
	else
		local subject:BasePart = Camera.CameraSubject==Humanoid and HumanoidRootPart or Camera.CameraSubject
		
		local delta = UIS:GetMouseDelta()*.5

		mouseDelta+=delta
		mouseDelta = Vector2.new(
			mouseDelta.X,
			math.clamp(mouseDelta.Y,-80,80)
		)
		
		local angle = CFrame.fromEulerAnglesYXZ(math.rad(-mouseDelta.Y),math.rad(-mouseDelta.X),0)
		angle = (Camera.CFrame-Camera.CFrame.Position):Lerp(angle,.8)
		
		local handler = CameraHandlers[ClientModules.CameraModule.CameraType] or BaseCamera
		Camera.CFrame = handler(
			subject,
			angle
		)
	end
end

-- Events
RunService:BindToRenderStep("CustomCamera",Enum.RenderPriority.Last.Value+100,update)

As well as lerping the CFrame altogether

return function(subject:BasePart,angle:CFrame)
	print("Follow")
	local Character = Player.Character
		local Humanoid:Humanoid = Character:FindFirstChild("Humanoid")
	
	local offset = Vector3.zero
	local lookVector = subject.CFrame.LookVector
	local rightVector = subject.CFrame.RightVector
	
	offset += rightVector*Humanoid.CameraOffset.X -- Left/Right
	offset += Vector3.yAxis*Humanoid.CameraOffset.Y -- Up/Down
	offset += lookVector*Humanoid.CameraOffset.Z -- Forward/Backward
	
	local pos = subject.Position+offset
	
	return Camera.CFrame:Lerp(CFrame.new(pos)*angle,.1)
end