Im making a character customization system right now, similar to how ATF: Wintertide does it
When you hold in the left mouse button, it rotates the camera on a pivot following the mouses direction
When you hold the right mouse button, it moves the camera on a plane following the mouses direction
Ive solved my issue with moving the camera on a plane using this script, but im unaware of how to make the camera rotate on a pivot, said pivot being the center of the screen/where the camera is pointing
local run = game:GetService("RunService")
local uis = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local cam = workspace.Camera
local speed = 1
local lockMouse = true
local origin = CFrame.lookAt(Vector3.new(0,10,0), Vector3.new(90, 0, 0))
local moved = Vector2.zero
local dragging = false
local oldMousePos = Vector2.zero
mouse.Button1Down:Connect(function()
dragging = true
oldMousePos = uis:GetMouseLocation()
end)
mouse.Button1Up:Connect(function()
dragging = false
uis.MouseBehavior = Enum.MouseBehavior.Default
end)
run.RenderStepped:Connect(function(dt)
if dragging then
if lockMouse then
uis.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition
moved += uis:GetMouseDelta()*speed*dt
else
moved += (uis:GetMouseLocation() - oldMousePos)*speed*dt
oldMousePos = uis:GetMouseLocation()
end
end
cam.CFrame = origin * CFrame.new(-moved.X*speed, 0, moved.Y*speed)
end)