How would i make this camera script smoother

Working on some camera system, kinda like fortnite STW’s camera system where its angled over a map and you can select missions and whatnot.

I’ve created a base for it, but it feels choppy.
Also the “controls” feels very wonky

Couldn’t get a answer for this so just made it normal directions Make camera movement diagonal

Code

-- Variables
local RunService = game:GetService("RunService")
local uis = game:GetService('UserInputService')
local Ts = game:GetService("TweenService")

-- math and stuff --
local clamp = math.clamp
local cfa = CFrame.Angles
local rad = math.rad
local cfn = CFrame.new
local v3n = Vector3.new
--                --

local player = game:GetService("Players").LocalPlayer
local camera = game.Workspace.CurrentCamera
local mouse = player:GetMouse()
local IsHeldDown = false

local Debug = true

local View = 25
local MinView = 10
local MaxView = 50

local DownCF = CFrame.Angles(0,rad(-90),0) * CFrame.Angles(rad(-45),0,0) 
local CurrentPos = v3n(0,0,0)
local Connection1
local Connection2

local part1 = Instance.new("Part", workspace); part1.Anchored = true; part1.Size = Vector3.new(1,1,1); part1.CanCollide = false; part1.CanQuery = false; part1.CanTouch = false
local part2 = part1:Clone(); part2.Parent = workspace
local part3 = part1:Clone(); part3.Parent = workspace

part1.Transparency = 0.8; part2.Transparency = 0.8; part3.Transparency = 0.8;
part1.Color = Color3.new(1,0,0); part2.Color = Color3.new(0,1,0); part3.Color = Color3.new(0,0,1)

-- Functions
local function Main()
	Connection1 = RunService.RenderStepped:Connect(function()
		local tH = (clamp(View,MinView,MaxView))/5
		local mP = mouse.Hit.Position
		
		local CamCFrame = cfn(v3n(CurrentPos.X, CurrentPos.Y + clamp(View, MinView, MaxView), CurrentPos.Z)) * DownCF
		
		if IsHeldDown then
			local MD = uis:GetMouseDelta()
			CamCFrame += v3n(MD.Y*.25,0,MD.X*.25)
			CurrentPos += v3n(MD.Y*.25,0,MD.X*.25)
		end

		if Debug then
			part1.Position = mP
			part2.Position = CurrentPos
			part3.Position = CamCFrame.Position - v3n(0, clamp(View, MinView, MaxView), 0)
		end
		
		Ts:Create(camera, TweenInfo.new(.2, Enum.EasingStyle.Quad,	Enum.EasingDirection.Out),{CFrame = CamCFrame}):Play()
	end)
end

local function Main2()
	coroutine.resume(coroutine.create(function()
		Connection2 = RunService.RenderStepped:Connect(function()
			if IsHeldDown then
				uis.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition
			else
				uis.MouseBehavior = Enum.MouseBehavior.Default
			end
		end)
	end))
end

-- Main
wait(2)
camera.CameraType = Enum.CameraType.Scriptable

mouse.WheelForward:Connect(function() 
	View = clamp((View - 4), 10, 50)
end)

mouse.WheelBackward:Connect(function()
	View = clamp((View + 4), 10, 50)
end)

uis.InputBegan:Connect(function(Input)
	if Input.UserInputType == Enum.UserInputType.MouseButton2 then
		IsHeldDown = true
	end
end)

uis.InputEnded:Connect(function(Input)
	if Input.UserInputType == Enum.UserInputType.MouseButton2 then
		IsHeldDown = false
	end
end)

Main2()
Main()

Can you send a video of what it looks like, or a .rbxm model file so we can try it for ourselves? Otherwise, don’t really know what the problem is.

You can probably use RunService.RenderStepped as thats what people use to make camera bobbing or animations smooth instead of Choppy like Stepped and Heartbeat.

Edit: did not look at the script correctly

You can use TweenService with a linear animation which is perfectly smooth instead of being choppy.

Sorry for the long response time but heres a video

I already use tweenservice, it just feels choppy with it for some reason

Also the movement feels horrible, could just be me though
CamTest.rbxl (29.0 KB)

Aha my bad, didn’t read the code properly :+1:

Honestly, looks fine to me. Not sure what you want it to look like though.


Kinda as smooth as this

Also the movement feels just weird somehow
like theres something wrong with the movement and i just cant explain what

The example you gave locks onto a specific part, so it just tweens the camera position there, you are moving the camera yourself. Also is this a local or a server script?