I am trying to make a custom camera system, similar to an over the shoulder camera but with the ability to still zoom in and out, but when I try to capture the mouse movement when the mouse behavior is set to lock center, it does not work and always returns 0,0,0. (See sample code below)
I notice that it picks up the mouse delta correctly if I hold the right mouse button and turn the camera in the default camera type, but it does not work moving it around normally.
I’ve tried searching for an answer and found this dev forum post and this camera manipulation article, but both did not help.
My Code
local ContextActionService = game:GetService("ContextActionService")
local UserInputService = game:GetService("UserInputService")
local camera = workspace.CurrentCamera
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
local function mouseMovement (actionName, inputState, inputObject)
print(inputObject.Delta) -- 0, 0, 0
end
ContextActionService:BindAction("MouseMovement",mouseMovement, false,Enum.UserInputType.MouseMovement, Enum.UserInputType.Touch)
game:GetService("RunService").RenderStepped:Connect(function()
camera.CameraType = Enum.CameraType.Scriptable
end)