Try this: instead of connecting the function to :RenderStepped, properly bind it to RenderStep with :BindToRenderStep. That way, you can set its priority.
I’m betting that your character updates at a RenderPriority of 300 (see Documentation - Roblox Creator Hub for more info), so the camera should update at a priority below that. (lower priority values get executed earlier)
RunService:BindToRenderStep(
"camera"
Enum.RenderPriority.Camera.Value,
yourUpdateFunction -- this is the function you would normally connect to :RenderStepped
)
I’ve already been doing this with BodyGyro and BodyPosition for a while and it worked perfectly, but the problem with that is that you need to have a physical part. I haven’t used springs yet, do they need a physical part or do they only need an attachment?
I don’t mean SpringConstraints, I meant some sort of spring module.
I’ll admit that I barely know what I’m talking about at this point since I’ve only ever used springs for simulating gun recoil and not for camera interpolation. I really didn’t expect your problem to be harder than playing around with :lerp and RenderStepped priorities.
local alpha = 0.5 -- A value between 0 and 1. 1 is instantaneous. 0 doesn't move at all.
Camera.CFrame = Camera.CFrame:lerp(goal, alpha)
Multiply the alpha by the dt. Increase alpha by some factor because we’re multiplying it by 1/60 on average. Also clamp it to between 0 and 1 so that it never overshoots when the framerate drops suddenly.
local alpha = math.clamp(0.5 * 60 * dt, 0, 1) -- dt goes here
Camera.CFrame = Camera.CFrame:lerp(goal, alpha)
If you’re using Stepped, then make sure you’re using the second parameter instead of the first one. The first parameter is the time since the game started, the second one is the actual dt.
(it would also help if we could see the code you have so far!)
So your solution currently works the best, there is none to very little jitter on low alpha values, but the higher I go the more jitter there is I want to use about 0.35-0.4 alpha because anything lower is too unresponsive, but that kind of alpha produces a lot of jitter. Here is my whole loop
game:GetService("RunService").Stepped:connect(function(first, dt)
--If character exists
if Character then
--Set rotated start cframe inside head
local startCFrame = CFrame.new((rootPart.CFrame.p + Vector3.new(0,2,0)))*CFrame.Angles(0, cameraYAngle, 0)*CFrame.Angles(cameraXAngle, 0, 0)
--Set camera focus and cframe
local cameraFocus = startCFrame + startCFrame:vectorToWorldSpace(Vector3.new(3.5,0,-50000))
local cameraCFrame = startCFrame + startCFrame:vectorToWorldSpace(Vector3.new(3.5,0,7.5))
--Lerp
local alpha = math.clamp(0.35 * 60 * dt, 0, 1)
local current = Camera.CFrame
local goal = CFrame.new(cameraCFrame.p,cameraFocus.p)
Camera.CFrame = current:lerp(goal, alpha)
end
end)
I tested it out on an old game of mine and the only thing that seems to be shaking is the player itself, as seen here: https://i.gyazo.com/e8f96239a3041475e12f5b3dd01b03b7.mp4
The video might not show it very well but the only thing that is shaking is the player
It’s definitely the camera not the player, the player is the closest thing to the camera which the camera follows thats why it seems like it’s just the player jittering.