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

Camera Interpolation sudden rotation?

Asked by
Rhidlor 42
5 years ago

So the following code works, but if you follow the link below and watch the gif you'll see it does some funky rotations and such. I haven't used Interpolate() too much, so I would like to know how I can smooth out this sudden rotation or if there is a better way to be doing this altogether? The goal of this code (which should be quite clear if you watch the gif) is to move the camera to an overhead view of the players plot, then back down to the default camera angle afterwards.

Any and all help is greatly appreciated, thanks!

https://gyazo.com/d9117cbc333e1bb5e1e69aad8ee9e556

function MoveCamera(Overhead)
    if Overhead then
        local Plot = GeneralModule.GetPlot(Player)
        if Plot then
            Camera.CameraType = Enum.CameraType.Scriptable
            Camera:Interpolate(Plot.CFrame + Vector3.new(0, 125, 0), Plot.CFrame, 1)
        end
    else
        local HeadCFrame = GetHeadCFrame()
        if HeadCFrame then
            Camera:Interpolate(HeadCFrame, HeadCFrame + HeadCFrame.LookVector * 2, 1)
            wait(1)
        end
        Camera.CameraType = Enum.CameraType.Custom
    end
end
0
Why not use lerp? TheLightningRises 56 — 5y

1 answer

Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
5 years ago

This is caused by forcing the camera to look directly down. Add 0.1 to your X or Z on line 6 and it'll be fine.

0
That makes sense, thanks for the help! Rhidlor 42 — 5y
Ad

Answer this question