Input.GetAxisRaw("Mouse X") is too chunky

Hi,
is there any way to make Input.GetAxisRaw(“Mouse X”) less chunky? Or do i have to change to the new Input System? Because my players y rotation is only going in 0.175 steps (i think). Below is the mouse part.

Thanks!

[SerializeField] float Sensivity = 3.5f;
private float mX, mY;

private void FixedUpdate() {
        mX += Input.GetAxisRaw("Mouse X") * Sensivity;
        mY -= Input.GetAxisRaw("Mouse Y") * Sensivity;
        mY = Mathf.Clamp(mY, minRotation, maxRotation);

        transform.rotation = Quaternion.Euler(0, mX, 0);
        camHeader.localRotation = Quaternion.Euler(mY, 0, 0);
    }

Luckily it isn’t necessary to guess. You can debug!

By debugging you can find out exactly what your program is doing so you can fix it.

Use the above techniques to get the information you need in order to reason about what the problem is.

You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.

Once you understand what the problem is, you may begin to reason about a solution to the problem.

Don’t use FixedUpdate() unless you’re using physics.

And if think you’re using physics, by directly accessing transform.rotation you are bypassing the physics API an can reasonably expect glitching by doing so. See below.

Also, you have a scaling variable already (the one you call “Sensivity” above)… make it smaller if the final scaled result is too large.


With Physics (or Physics2D), never manipulate the Transform directly. If you manipulate the Transform directly, you are bypassing the physics system and you can reasonably expect glitching and missed collisions and other physics mayhem.

This means you may not change transform.position, transform.rotation, you may not call transform.Translate(), transform.Rotate() or other such methods, and also transform.localScale is off limits. You also cannot set rigidbody.position or rigidbody.rotation directly. These ALL bypass physics.

Always use the .MovePosition() and .MoveRotation() methods on the Rigidbody (or Rigidbody2D) instance in order to move or rotate things. Doing this keeps the physics system informed about what is going on.

1 Like

Hi, thanks for the VERY LONG RESPONSE!
i will put it in Update() later (I thought it wouldnt make a difference (hopefully it will))

Thanks, Update() and times Time.deltaTime helped.

I used print(…) which is the same, i said i think because i wasnt sure if it was .125 or .175, but Input.GetAxisRaw(“Mouse X”) was .05 when moving one pixel to the right