Hello. I’ve been looking for a solution to my problem, and cannot seem to find one. I am trying to make my camera move around an axis that is my character whenever the mouse is clicked and dragged. For example: say I clicked my mouse and dragged the screen to the right. This should cause the camera to move around the axis to the left, as is:
I’m assuming I need mouse delta to do this. Here’s my script so far (which only detects mouse clicks and mouse delta):
local module = {}
function module:initiate(plr, ui, network, util, assets, event, script)
local action = util.service "ContextActionService"
local uis = util.service "UserInputService"
local runtime = util.service "RunService"
local cam = workspace.CurrentCamera
local blank = Vector3.new()
local mousedown = false
local mdelta = blank
action:BindAction("MouseMovement", function(name, state, input)
local delta = input.Delta
if delta == blank then return end
mdelta = delta
end, false, Enum.UserInputType.MouseMovement)
action:BindAction("Mouse1Hold", function(name, state, input)
if state == Enum.UserInputState.Begin then
uis.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition
mousedown = true
elseif state == Enum.UserInputState.End or state == Enum.UserInputState.Cancel then
uis.MouseBehavior = Enum.MouseBehavior.Default
mousedown = false
end
end, false, Enum.UserInputType.MouseButton1)
end
return module
How can I make it so the camera faces toward the character and moves around the character according to where the camera is dragged?
If anything I talked about was inconclusive please let me know and I will try to elaborate.