I found a script that lets you pan the camera from a top down, Top Down Camera Pan [Open Source] - #4 by KUW_Alt1, but I had to make it work horizontally. But for some reason it’s a little “smooth”. I thought it was the lag of the tiles but it isn’t.
If I let go of the pan button, then it abruptly stops. I want the entire panning thing to but non-smooth.
Code:
local runService = game:GetService("RunService")
local camera = workspace.CurrentCamera
local mouse = player:GetMouse()
local uis = game:GetService("UserInputService")
local dragging = false
local PAN_SPEED = 10
local lastDragPosition
camera.CFrame = CFrame.new(Vector3.new(0,0,-50)) * CFrame.Angles(0,math.rad(180),0)
camera.CameraType = Enum.CameraType.Scriptable
camera.FieldOfView = 50
runService.RenderStepped:Connect(function(dt)
if dragging then
local delta = Vector3.new(mouse.Hit.Position.X,mouse.Hit.Position.Y,0) - lastDragPosition
camera.CFrame = CFrame.new(camera.CFrame.Position + -delta * dt * PAN_SPEED) * CFrame.Angles(0,math.rad(180),0)
end
end)
uis.InputBegan:Connect(function(input,gpe)
if input.UserInputType == Enum.UserInputType.MouseButton3 then
dragging = true
lastDragPosition = Vector3.new(mouse.Hit.Position.X,mouse.Hit.Position.Y,0)
end
end)
uis.InputEnded:Connect(function(input,gpe)
if input.UserInputType == Enum.UserInputType.MouseButton3 then
dragging = false
end
end)