How to make this camera smoothly around this map?

I’m trying to do a cutscene where the camera goes through the cave and see the monster. It works but I want it to look more smooth. Here’s a video.


first part of the vid lags but u see the cutscene still.

This is the script too.

cutremotes.MudgrimBreakIn.OnClientEvent:Connect(function()
	local ti1 = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0)
	local ti2 = TweenInfo.new(3, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0)
	local ti3 = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0)
	local ti4 = TweenInfo.new(6, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0)

	local goal1 = {CFrame = camfolder.MudgrimBreakIn.MGBreakInCam1.CFrame}
	local goal2 = {CFrame = camfolder.MudgrimBreakIn.MGBreakInCam2.CFrame}
	local goal3 = {CFrame = camfolder.MudgrimBreakIn.MGBreakInCam3.CFrame}
	local goal4 = {CFrame = camfolder.MudgrimBreakIn.MGBreakInCam4.CFrame}
	goal4.FieldOfView = 45

	local animation1 = ts:Create(Camera, ti1, goal1)
	local animation2 = ts:Create(Camera, ti2, goal2)
	local animation3 = ts:Create(Camera, ti3, goal3)
	local animation4 = ts:Create(Camera, ti4, goal4)

	Player.Character.SprintScript.Enabled = false
	script.Parent.MainUI.Enabled = false

	Camera.CameraType = "Scriptable"

	animation1:Play()
	wait(2)
	animation2:Play()
	wait(3)
	animation3:Play()
	wait(2)
	animation4:Play()
end)

2 Likes

You’re probably looking for splines. It’s when you create a smooth path from multiple points. You can use it for the camera by putting points all across the map. There’s a lot of math involved, but there’s plenty of community modules available.

Here’s one module I found:

2 Likes

This is kind of confusing for me, but I’ll try to understand it!

I’m confused on why you’re not just lerping the camera, or is there a specific reason on you using tweens

I use tweens cuz i dont know how to use lerps.

Lerping is basically the better version of tweens and if you use workspace.Camera:Lerp(Cframe, Time)
then it will make everything smoother. try to do this for now and reply back to me once you get a result

1 Like

it says “attempt to call missing method ‘Lerp’ of table”

Camera.CFrame = CFrame:Lerp(camfolder.MudgrimBreakIn.MGBreakInCam1.CFrame, 2)
	wait(2)
	Camera.CFrame = CFrame:Lerp(camfolder.MudgrimBreakIn.MGBreakInCam2.CFrame, 3)
	wait(3)
	Camera.CFrame = CFrame:Lerp(camfolder.MudgrimBreakIn.MGBreakInCam3.CFrame, 2)
	wait(2)
	Camera.CFrame = CFrame:Lerp(camfolder.MudgrimBreakIn.MGBreakInCam4.CFrame, 6)

am i doing smth wrong

2 Likes

Try this

	task.wait(2)
	Camera.CFrame:Lerp(camfolder.MudgrimBreakIn.MGBreakInCam2.CFrame, 3)
	task.wait(3)
	Camera.CFrame:Lerp(camfolder.MudgrimBreakIn.MGBreakInCam3.CFrame, 2)
	task.wait(2)
	Camera.CFrame:Lerp(camfolder.MudgrimBreakIn.MGBreakInCam4.CFrame, 6)```
2 Likes

theres no errors but it doesnt move the camera tho

Set the camera type to scriptable

it already at scriptable, like the camera no longer follows the player but js stays still

cam.CFrame = cam.CFrame:Lerp(workspace["Meshes/Turret"].CFrame, 3) 

try to do something like this

after a little tweaking it works thanks!

cutremotes.MudgrimBreakIn.OnClientEvent:Connect(function()
	local cam1 = camfolder.MudgrimBreakIn.MGBreakInCam1
	local cam2 = camfolder.MudgrimBreakIn.MGBreakInCam2
	local cam3 = camfolder.MudgrimBreakIn.MGBreakInCam3
	local cam4 = camfolder.MudgrimBreakIn.MGBreakInCam4
	local ti = TweenInfo.new(17, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut,0)
	local goal = {}
	goal.FieldOfView = 45
	local animation = ts:Create(Camera, ti, goal)

	-- Function to move the camera continuously without pauses
	local function moveCamera(fromCFrame, toCFrame, duration)
		local startTime = tick()
		local endTime = startTime + duration

		-- Continuously update the camera position using Lerp
		while tick() < endTime do
			local elapsed = tick() - startTime
			local alpha = math.clamp(elapsed / duration, 0, 1)
			Camera.CFrame = fromCFrame:Lerp(toCFrame, alpha)
			runService.Heartbeat:Wait() -- Wait for the next frame
		end

		-- Ensure the camera is exactly at the target CFrame when done
		Camera.CFrame = toCFrame
	end

	-- Disable player controls and UI
	Player.Character.SprintScript.Enabled = false
	script.Parent.MainUI.Enabled = false
	Player.PlayerGui.FPBodyScript.Enabled = false
	Camera.CameraType = "Scriptable"

	-- Perform the camera transitions with Lerp continuously
	animation:Play()
	moveCamera(Camera.CFrame, cam1.CFrame, 1)
	moveCamera(cam1.CFrame, cam2.CFrame, 2)
	moveCamera(cam2.CFrame, cam3.CFrame, 0.5)
	moveCamera(cam3.CFrame, cam4.CFrame, 6)
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.