Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

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

Discussion in 'Input System' started by Luemus, Feb 24, 2021.

  1. Luemus

    Luemus

    Joined:
    May 20, 2013
    Posts:
    101
    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:

    Code (CSharp):
    1.     private void Start()
    2.     {
    3. //...
    4.         _inputActionMap.FindAction("Look").performed +=
    5.             context => ProcessCamera(context.ReadValue<Vector2>());
    6. //...
    7. }
    Code (CSharp):
    1.     private void ProcessCamera(Vector2 direction)
    2.     {
    3.         var mouseX = direction.x * cameraSensitivity;
    4.         var mouseY = direction.y * cameraSensitivity;
    5.  
    6.         _cameraXRotation -= mouseY;
    7.         _cameraXRotation = Mathf.Clamp(_cameraXRotation, -80, 80);
    8.        
    9.         playerCamera.localRotation = Quaternion.Euler(_cameraXRotation, 0, 0);
    10.         playerBody.Rotate(Vector3.up * mouseX);
    11.     }
    upload_2021-2-24_18-8-1.png
     
  2. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,688
  3. Luemus

    Luemus

    Joined:
    May 20, 2013
    Posts:
    101
  4. Putcho

    Putcho

    Joined:
    Jun 1, 2013
    Posts:
    246
    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
     
    Luemus likes this.
  5. Luemus

    Luemus

    Joined:
    May 20, 2013
    Posts:
    101
    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?
     
  6. Putcho

    Putcho

    Joined:
    Jun 1, 2013
    Posts:
    246
    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
     
    Last edited: Feb 25, 2021
    Luemus likes this.