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

How would I lerp or interpolate camera from one part to the second part in a loop?

Asked by 5 years ago

I've been trying to make a camera move from one part to second part and then back to one part to the second part and so on in a loop. I've been using :Interpolate within a loop, but that doesn't seem to be working. Here is the code anyways.

local Player = game.Players.LocalPlayer

repeat wait() until Player.Character

local camera = game.Workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable

local PosOne = game.Workspace.CameraA.CFrame
local FocusOne = game.Workspace.CameraA.CFrame + game.Workspace.CameraA.CFrame.lookVector
local PosTwo = game.Workspace.CameraB.CFrame
local FocusTwo = game.Workspace.CameraB.CFrame + game.Workspace.CameraB.CFrame.lookVector

camera.CFrame = game.Workspace.CameraA.CFrame
while true do
    camera:Interpolate(
        PosTwo,
        FocusTwo,
        5
    )
    wait()
    camera:Interpolate(
        PosOne,
        FocusOne,
        5
    )
end

Do you guys got better suggestions? Should I use :Lerp instead of :Interpolate? How would I do it in a loop? Thanks!

1
:lerp is how you do it :interpolate is how you would do it in objective-c Dev_Coda 31 — 5y

Answer this question