Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How does one calculate mouse Delta when the mouse behavior isn't locked?

Asked by 4 years ago

What I'm doing is moving the camera based on mouseInput.Delta but roblox only calculates that when the mouse is locked. Every rendereStepped the camera faces the "angleX" which is changed when the mouseInput.Delta has occurred. However, I only have the camera move when a tool is equipped therefore when it is unequipped I have to continue finding the delta, so when you re-equip the tool, the camera faces towards the mouse. Here is what I did so far but it doesn't seem to being working quite right, any ideas?

function mouseMoved(nameOfBind,inputState,inputObject) --mouse delta is calculated but only when the mouseBehavior is locked.
    AngleX = AngleX - inputObject.Delta.X
    AngleY = AngleY - inputObject.Delta.Y
end

mouse.Move:Connect(function()
    if mouse.X ~= previousX then
        angleX = angleX + (previousX - mouse.X)
        previousX = mouse.X
    end
end)

Answer this question