Why does my FPS camera rotates faster on lower frame rates?

I have a simple first-person controller setup and today I've noticed that the camera becomes more sensitive on lower frame rates. Here is the setup and code that I use:

    private void Start()
    {
//...
        _inputActionMap.FindAction("Look").performed +=
            context => ProcessCamera(context.ReadValue<Vector2>());
//... 
}
    private void ProcessCamera(Vector2 direction)
    {
        var mouseX = direction.x * cameraSensitivity;
        var mouseY = direction.y * cameraSensitivity;

        _cameraXRotation -= mouseY;
        _cameraXRotation = Mathf.Clamp(_cameraXRotation, -80, 80);

        playerCamera.localRotation = Quaternion.Euler(_cameraXRotation, 0, 0);
        playerBody.Rotate(Vector3.up * mouseX);
    }

6872252--802118--upload_2021-2-24_18-8-1.png

[quote=“Luemus”, post:1, topic: 830227]
camera becomes more sensitive on lower frame rates
[/quote]
https://docs.unity3d.com/ScriptReference/Time-deltaTime.html

I think you forgot to calculate with frametime.

[quote]
https://docs.unity3d.com/ScriptReference/Time-deltaTime.html

I think you forgot to calculate with frametime.
[/quote]

Sadly that doesn't fix the issue.

Delta [Pointer] is not normalize by default, its mean the value greater than 1 or lesser than -1, multiply by sensitivity and that is cost a large scale of movement

this is how i fix my delta

1 Like

[quote=“Putcho”, post:4, topic: 830227]
Delta [Pointer] is not normalize by default, its mean the value greater than 1 or lesser than -1, multiply by sensitivity and that is cost a large scale of movement

this is how i fix my delta

[/quote]

Oh, I didn’t know that it wasn’t normalized. Thanks a lot, however, it doesn’t feel as smooth/responsive as it used to be now. Any ideas on improving that?

[quote=“Luemus”, post:5, topic: 830227]
Oh, I didn’t know that it wasn’t normalized. Thanks a lot, however, it doesn’t feel as smooth/responsive as it used to be now. Any ideas on improving that?
[/quote]

i dont know what kind of camera rotation technique you are using, but here some API for most common use for smooth

for vector 2
https://docs.unity3d.com/ScriptReference/Vector2.SmoothDamp.html
for single axis Float
https://docs.unity3d.com/ScriptReference/Mathf.SmoothDampAngle.html
for quaternion
https://docs.unity3d.com/ScriptReference/Quaternion.Slerp.html
or
https://docs.unity3d.com/ScriptReference/Quaternion.SlerpUnclamped.html

i recommend to try Mathf.SmoothDamp for mouseX and mousY
https://docs.unity3d.com/ScriptReference/Mathf.SmoothDamp.html

1 Like