1
votes

i am working on camera rotations based on mouseInput and i want it to have consistent sensitivity across all framerates. According to the unity documentation, the Input.GetAxis should be inherently framerate independent for the mouse movement.

What I am finding is that when i use the code below and change the framerate from 200+ to 30, the Input.GetAxis is returning very different outputs. For 200+ fps the GetAxis is low around like 2-5 where for 30 fps it is returning around 10-15 for the same mouse movements. Its causes a very drastic sensitivity difference in-game. Am i missing something? Thanks

    public Rigidbody _playerRigidBody;
private Vector2 _lookInput;
private void Start()
{
    //Application.targetFrameRate = 30;
}
private void Update()
{
    _lookInput.x = Input.GetAxis("Mouse X"); 

}

void FixedUpdate()
{
    var sensitivity = 300f;
    var newPlayerRotation = _playerRigidBody.rotation * Quaternion.Euler(_lookInput.x * sensitivity * Vector3.up * Time.deltaTime);
    _playerRigidBody.MoveRotation(newPlayerRotation);

}

}

I have tested everything in this little function and the only thing that causes the issue is the Input.GetAxis. Its inconsistent. Any ideas or solutions or workarounds?

1

1 Answers

2
votes

"framerate independent" means the value is depend on the movement of the mouse, it doesn't mean the value is consistent.

For framerate = 200, value = 2-5 means the mouse move 2-5 points in 1/200 seconds.

So to get the move distance during 1 second use:

_lookInput.x = Input.GetAxis("Mouse X") / Time.deltaTime;