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

How does roblox calculate mouse acceleration?

Asked by
Edenojack 171
8 years ago

I'm currently making some changes to my Camera script, and someone mentioned that Roblox has Mouse Acceleration on and they didn't like it. Because I'm making my own version of the camera, I'd like to be able to add the option to disable this. But I can't work out how to get it to work :S Is there any good documentation on this?

So after eLunate's answer I've edited my script from changing all changes in Delta to 1, 0 or -1 by using the following:

            local MoveX = type.Delta.X
            local MoveY = type.Delta.Y
            if MouseAccel == false then
                print("Ay")
                MoveX = math.sqrt(type.Delta.X)
                MoveY = math.sqrt(type.Delta.Y)
                print(type.Delta, " Compared to: ",MoveX,"",MoveY)

However, I am recieving the following prints:

-7, -2, 0  Compared to:  -1.#IND  -1.#IND
Ay
-5, -1, 0  Compared to:  -1.#IND  -1.#IND
Ay
-6, -3, 0  Compared to:  -1.#IND  -1.#IND
Ay
-4, 0, 0  Compared to:  -1.#IND  0

Any suggestions?

1
It's as a power of the difference in position. User#6546 35 — 8y
0
So, when it says the delta is 36, its actually 6^2? Edenojack 171 — 8y
0
Can't sqrt negative numbers (Imaginary/indefinite result) User#6546 35 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

You can't get the root of negative numbers
Think positive

In order to get the root of a negative number, you can probably try something like this:

local _sqrt = math.sqrt;
local sqrt = function(n)
  _n = _sqrt(math.abs(n));
  if n < 0 then
    return -_n
  end
  return _n
end
Ad

Answer this question