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.