Any better solutions to making a spring camera not jittery?

Hi, I’ve been making a spring camera. It was being jittery so I found a solution and it looks like:

local physicsStep = 0

RunService:BindToRenderStep("Camera", 200, function(deltaTime)
	if localPlayer.Character then
		cameraSpring.goal = localPlayer.Character.HumanoidRootPart.Position + Vector3.new(0, math.tan(math.rad(CAMERA_ANGLE)) * distance, distance)

		cameraSpring:Step(physicsStep)

		camera.CFrame = CFrame.new(cameraSpring.position) * CFrame.Angles(math.rad(-CAMERA_ANGLE), 0, 0)
	end
end)

task.spawn(function()
	while task.wait() do
		physicsStep = RunService.RenderStepped:Wait()
	end
end)

But, to me, it seems a little hacky is there a better solution than this or a better way to get the physics time step? It also seems very unreliable with sometimes using delta time being less jittery than it.

Edit: For anyone who has this problem soltypotter made a pretty good post Short form guide to solving physics-based spring jitter! - Resources / Community Resources - DevForum | Roblox

1 Like

This is a really good open source module I use for my camera shakes, might be useful to you

2 Likes

Hi, thanks for the answer but, I’m pretty solid the problem isn’t with my spring module but the timestep.

Hey, maybe you could tween the camera for a smooth transition

1 Like

Try removing task.wait and replace it with true.

It is currently waiting task.wait (equal to heartbeat step), then wait for renderstep causing extra delays.

1 Like

Adding onto @dthecoolest 's comment. Use game:GetService("RunService").Heartbeat:connect(function() end) instead of while loops

1 Like

Thanks for the idea, but the tween didn’t work unfortunately.

Hi this is the problem @dthecoolest said in his post it is waiting for heartbeat then the renderstep.

Thanks! I think this worked A LOT BETTER and I don’t even think there are any jitters now :smile:.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.