Camera lerping issue

I’m making a dynamic camera for a main menu, but when I add lerping it behaves weirdly.
Without lerping everything works fine.

camera.CameraType = Enum.CameraType.Custom
	camera.CFrame = workspace.CameraPoint.CFrame
	
	local offset2 = CFrame.new()
	local random = Random.new(130413)
	coroutine.wrap(function()
		while true do
			offset2 = CFrame.new(random:NextInteger(-1.5, 1.5), random:NextInteger(-1.5, 1.5), 0)
			task.wait(1.5)
		end	
	end)()
	
	runService:BindToRenderStep("CameraLobby", Enum.RenderPriority.Camera.Value + 1, function(del)
		local offset = CFrame.new()
		
		local mousePos = userInputService:GetMouseLocation()
		mousePos = Vector2.new(mousePos.X, mousePos.Y)
		local offset1 = CFrame.Angles(
			math.rad((-(mousePos.Y - camera.ViewportSize.Y) / camera.ViewportSize.Y) * 3),
			math.rad((-(mousePos.X - camera.ViewportSize.X) / camera.ViewportSize.X) * 3),
			0
		)
		offset *= offset1 * offset2
		
		camera.CameraType = Enum.CameraType.Custom
		camera.CFrame = camera.CFrame:Lerp(workspace.CameraPoint.CFrame * offset, 0.1)
	end)

I can provide a video if needed.
I don’t see any mistakes in calculations, can’t figure out what’s wrong.

1 Like

You might want to use Tween for this case.

local TweenService = game:GetService("TweenService")
TweenService:Create(camera, TweenInfo.new(0.1), {["CFrame"] = workspace.CameraPoint.CFrame * offset}):Play()

Lerp is a type of Tween, so yeah

I can’t just create a tween every frame.

Did you try using deltaTime instead of 0.1?

The delay between two frames is too small for an alpha in my case.

Multiply it then? that would totally do the trick

I remembered why I don’t use it, makes the camera shake weirdly.