But I don’t got too much of an idea on how to make the camera draggable. Hold down left click to to activate it, then whilst holding down left click you can pan around, like the Sims 4.
Any ideas on you this could be achieved?
I know that’s it’s possible by using connecting functions to the W, A, S, D keys, but I’d like to be able to move around with the mouse as it feels a lot better than keys, and can probably be mobile compatible as well.
Maybe UserInputService:GetMouseDelta() would work. It only works when the mouse is locked (the cursor can’t move), so try setting UserInputService.MouseBehavior to Enum.MouseBehavior.LockCurrentPosition every frame when UserInputService:IsMouseButtonDown(Enum.UserInputType.MouseButton1) returns true.
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local MULTIPLIER = 10
local cam = workspace.CurrentCamera
RunService.RenderStepped:Connect(function()
if UserInputService:IsMouseButtonDown(Enum.UserInputType.MouseButton1) then
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
local mouseDelta = UserInputService:GetMouseDelta()
cam.CFrame += Vector3.new(mouseDelta.X*MULTIPLIER, 0, mouseDelta.Z*MULTIPLIER)
end