Mouse Delta When Mouse Is Moving

I want to get Mouse Delta without changing UserInputService.MouseBehavior, but when set to default it returns a zero-vector. How can I get the delta while mouse is moving?

You can calculate the mouse delta by using the UserInputService.MouseMovement event.

local ContextActionService = game:GetService("ContextActionService")
local UserInputService = game:GetService("UserInputService")

local lastMousePosition = nil

function onMouseMove(input)
    if lastMousePosition then
        local mouseDelta = input.Position - lastMousePosition
        
    end

    lastMousePosition = input.Position
end

UserInputService.MouseMovement:Connect(onMouseMove)

Thanks, but I’m coding custom camera movement, so I’ll just put it inside my renderstepped loop

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.