Making camera rotation smoother and tween?

Hey there! so i have this camera rotation system in place and when i activate the rotation, it just instantly snaps. How would i make it so it quickly tweens into rotation?

local status = 0
local camera = workspace.CurrentCamera
local rss = game:GetService("RunService")
local angle = 0
local rate = 20 / 0

local function rotate()
	camera.FieldOfView = 90
	rss.RenderStepped:Connect(function()
		camera.CFrame = CFrame.lookAt(camera.CFrame.Position, camera.CFrame.Position + camera.CFrame.LookVector) * CFrame.Angles(0, 0, math.rad(angle))
	end)

	if (status == 0) then
		status = 2
		while (angle < 20) do
			local t = rss.RenderStepped:Wait()
			angle = angle + rate * t
		end
		angle = 20
		status = 1
	end
end

game.ReplicatedStorage.WallrunTilt.OnClientEvent:Connect(function(e)
	if e == "start" then
		rotate()
	else
		camera.FieldOfView = 70
		status = 2
		while (angle > 0) do
			local t = rss.RenderStepped:Wait()
			angle = angle - rate * t
		end
		angle = 0
		status = 0
	end
end)

thanks! im pretty bad at CFrames and tweening so yeah…

1 Like

Its pretty easy to use cframe:lerp(), you can do: camera.CFrame = camera.CFrame:Lerp(newcframehere, .5 "you can change this between 0 and 1" )

2 Likes

tried it and it still seems to snap unfortunately

The second parameter determines pretty much how smooth the lerp is, try changing the value to near 0 or near 1.

1 Like