hey all, I am trying to figure out how to make it so when your mouse goes to one side of the screen, it moves the camera until a certain point. and, at the end of the movement, it snaps. how can i make it more smooth?
local RunService = game:GetService("RunService")
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local cam = game.Workspace.CurrentCamera
cam.CameraType = "Scriptable"
local camCF = workspace.gamer.CFrame
local angle = 0
local savedCF = camCF
RunService.RenderStepped:Connect(function()
local center = Vector2.new(cam.ViewportSize.X / 2, cam.ViewportSize.Y / 2)
local rotVector = Vector3.new(((mouse.X - center.X) / 150), (mouse.Y - center.Y) / 150, 0)
if mouse.X < 250 and angle > -100 then
print("panning left")
angle = angle - 3
cam.CFrame = savedCF * CFrame.Angles(0, math.rad(math.cos(cam.CFrame.Y + (angle / 750))), 0)
savedCF = cam.CFrame
wait(0.1)
elseif mouse.X > 1750 and angle < 100 then
print("panning right")
angle = angle + 3
cam.CFrame = savedCF * CFrame.Angles(0, -math.rad(math.cos(cam.CFrame.Y + (angle / 750))), 0)
savedCF = cam.CFrame
wait(0.1)
else
cam.CFrame = savedCF * CFrame.Angles(math.atan(math.rad(-rotVector.Y)), math.atan(math.rad(-rotVector.X)), rotVector.Z)
end
end)