Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Camera Interpolation sudden rotation?

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

1 comment

0

Why not use lerp?

1 answer

✓ Accepted answer

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.

1 comment

0

That makes sense, thanks for the help!

This discussion is preserved as it was. New answers, comments, and votes are closed.