Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I lerp camera movement?

Asked by 3 years ago

I'm trying to make a camera leaning script that involves the camera. Everything works, but I want to know how to make the camera transition smooth.

function Lean()
    if Leaning == true then -- Detects if the player is leaning
        if LeanDirection == "Right" then -- Detects if the player is leaning Right
            PreviousLean = "Right"
            LeanAmount = 1
        else  -- Detects if the player is leaning Left
            PreviousLean = "Left"
            LeanAmount = -1
        end
    else if Leaning == false then
            PreviousLean = "None"
            LeanAmount = 0
        end 
    end
end

game:GetService("RunService").RenderStepped:Connect(function()
    local Lean = CFrame.fromAxisAngle(Vector3.new(0, 0, 1), LeanAmount)
    Camera.CFrame = Camera.CFrame:Lerp(Camera.CFrame * Lean, 0.1) 
end)

Answer this question