Lerping the camera in RenderStepped

What is the correct way in which to do this, I notice visual jittering and it’s kinda buggy. Should I be incorporating deltatime somewhere or should my goal CFrame be different?

game:GetService("RunService"):BindToRenderStep("Yeet", Enum.RenderPriority.Camera + 1, function()
    Camera.CFrame:Lerp(
        CFrameGoal
        0.5
    )
end)

Thanks! :grinning_face_with_smiling_eyes:

1 Like

Is there any reason why you can’t use TweenService to move the camera?

Unless I make sure that there’s only a single tween running and waiting till it’s complete, I can’t use TweenService as creating a tween every frame is undesirable and not intended use.
Linear interpolation has a set calculated timeframe to interpolate and only requires a fraction as to how close the target instance should be from the goal.

Well… the idea is you would let TweenService handle the camera updates. Not start a new one every frame. It should be easy to implement too. All you really need is a final camera CFrame and the length of the tween in seconds.

RunService:BindToRenderStep("Yeet", Enum.RenderPriority.Camera.Value, function()
    Camera.CFrame = Camera.CFrame:Lerp(CFrameGoal, 0.5)
end)
1 Like

The reason it’s in RenderStepped is because it’s constantly changing lol.

Maybe code would help explain:

local TweenService = game:GetService("TweenService")

local cameraTween = TweenService:Create(workspace.CurrentCamera, TweenInfo.new(), {CFrame = CFrame.new(100, 0, 0)})

cameraTween:Play()

If you’re looking to ease the camera’s position to single ending position then this is your solution. It’s a little unclear what your final product is trying to be so I’m just going to assume that this isn’t for creating something like a little camera animation, but something that would modify the behavior of the player’s camera. If that’s your goal, TweenSerivce isn’t for this. On the other hand, it this is what you’re trying to do and you haven’t already done so, try forking the default camera scripts.