Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

CineMachine and Framerate

Discussion in 'Cinemachine' started by tnaseem, May 5, 2018.

  1. tnaseem

    tnaseem

    Joined:
    Oct 23, 2009
    Posts:
    149
    Unity 2017.4.2f2 // CineMachine 2.1.10 (with fix for Animator Override Controller, kindly supplied earlier)

    I have a CineMachineStateDrivenCamera driving two third person view virtual cameras - ground based and 'flight' based cameras. I use the mouse/joypad to rotate around the player. All working well and moving between the two nicely.

    However, I've come across an issue where it appears that the X and Y axis max speeds of the cameras don't appear to be framerate independent.

    I had it running really well on my local dev system, but on my client's low-end system, where the framerates are lower, the control of the camera rotation are far too sensitive. This made me wonder if the max speeds are not framerate independent and if there's a workaround?

    I've tried playing with the settings in CineMachine Brain (Ignore Time Scale and Update Method) but nothing seems to work.

    Obviously, ideally, I want to rotate the camera at the same speed regardless of framerate. Any help or advice appreciated!
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Sorry for the delayed response.
    The code in question is in AxisState.Update(). It's taking deltaTime into account when applying acceleration to the axis. DeltaTime will vary with the framerate, so the acceleration strength is framerate-dependent, but the max speed is not. What are your axis settings?
     
    Last edited: Jun 5, 2019
  3. mechturtle

    mechturtle

    Joined:
    Feb 3, 2018
    Posts:
    3
    I am getting similar issues. In the editor, where my framerate is lower, the sensitivity seems fine the way I have it set up. When I build and test and the framerate is much higher there is a very noticeable difference in sensitivity for both X and Y.

    I am using Cinemachine Free Look. Y Axis Max Speed of 4 and X Axis Max Speed of 500. I am using 0.1 Acceleration and Deceleration times for both axes, but I tested it with both times set to 0 as well and still noticed the problem.

    Any suggestions?
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    One possibility is to completely replace the way the axis value is driven.

    Here is a little script that does exactly that. It makes use of a new feature in CM 2.2.9: CinemachineInputAxisDriver, which is an alternative input axis driver giving a snappier mouse response.

    Add this script to your FreeLook and give it a spin. Let me know how that goes.
     

    Attached Files:

    baumxyz and Mikhail94 like this.
  5. inder8288_unity

    inder8288_unity

    Joined:
    Aug 20, 2019
    Posts:
    2
    Hey there! I have also have this kinda issue. I am using "Cinemachine touch Input mapper" to get values of x and y axis;
    Touch seems to be so responsive. With a little drag on android touch screen, CM camera moves so quickly, even my x and y speed are 10 or less. Is there any solution to this?
    Here is how x and y axis's values are driven

    Code (CSharp):
    1.  
    2. public class CameraManager : MonoBehaviour
    3. {
    4.  
    5.     public float TouchSensitivity_x = 10f;
    6.     public float TouchSensitivity_y = 10f;
    7.     public bool canControlCamera = false;
    8.  
    9.     // Use this for initialization
    10.     void Start()
    11.     {
    12.         CinemachineCore.GetInputAxis = HandleAxisInputDelegate;
    13.     }
    14.  
    15.     float HandleAxisInputDelegate(string axisName)
    16.     {
    17.         if (canControlCamera)
    18.         {
    19.             switch (axisName)
    20.             {
    21.  
    22.                 case "Mouse X":
    23.  
    24.                     if (Input.touchCount > 0)
    25.                     {
    26.                         return Input.touches[0].deltaPosition.x / TouchSensitivity_x;
    27.                     }
    28.                     else
    29.                     {
    30.                         return Input.GetAxis(axisName);
    31.                     }
    32.  
    33.                 case "Mouse Y":
    34.                     if (Input.touchCount > 0)
    35.                     {
    36.                         return Input.touches[0].deltaPosition.y / TouchSensitivity_y;
    37.                     }
    38.                     else
    39.                     {
    40.                         return Input.GetAxis(axisName);
    41.                     }
    42.  
    43.                 default:
    44.                     Debug.LogError("Input <" + axisName + "> not recognyzed.", this);
    45.                     break;
    46.             }
    47.         }
    48.  
    49.         return 0f;
    50.     }
    51.  
    52.     public void SetCanControlCameraValue(bool val)
    53.     {
    54.         canControlCamera = val;
    55.         print(val);
    56.     }
    57. }
     

    Attached Files:

  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Can you try out the new feature in CM 2.4.0? It offers better axis control and may solve the problem for you.

    upload_2020-1-6_11-23-31.png
     
  7. inder8288_unity

    inder8288_unity

    Joined:
    Aug 20, 2019
    Posts:
    2
    Thanks for replying so fast. I found the solution to problem today. I have updataed CM to CM 2.4 preview. Btw I dont have any idea of this new option. Anyway thanks!
     
  8. samj51590

    samj51590

    Joined:
    Jul 24, 2021
    Posts:
    2
    I am using CineMachine POV for an FPS game. I have no scripts for looking around. CineMachine is taking mouse input and rotating the camera. I am currently using Input Value Gain, and the sensitivity is okay. Is this framerate independent? If not, how can I fix it so that my camera movement becomes framerate independent?
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    It is supposed to be framerate-independent
     
    samj51590 likes this.
  10. Grant151

    Grant151

    Joined:
    Sep 12, 2013
    Posts:
    65
    I am using Cinemachine Free Look with Input Value Gain, Mouse X / Y axis, and cinemachine brain set to fixed update. But I can clearly feel that with lower FPS the camera rotation is faster. In particular, the Input Axis Values are much higher at lower FPSs.

    Is there a fix for that?
     
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    It turns out that there is a CM bug related to framerate that produces this effect for FixedUpdate cameras. It's been fixed on the CM main branch, and will be part of the next CM release.
     
    urilache likes this.
  12. Grant151

    Grant151

    Joined:
    Sep 12, 2013
    Posts:
    65
    Got it, thanks
     
  13. urilache

    urilache

    Joined:
    Nov 23, 2013
    Posts:
    7
    Do you happen to have a date for the release?
    Will it also be part of a verified package for Unity 2020.3.x versions?

    Thank you
     
  14. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Yes we are planning a backport of this fix to 2.6.x and 2.7.x. Don't have a date yet.
     
    urilache likes this.
  15. ColtPtrHun

    ColtPtrHun

    Joined:
    Nov 20, 2019
    Posts:
    9
    Hi!
    I had the same problem.
    However, choosing "Input Value Gain" instead of "Max Speed" as the Speed Mode solved the problem for me.
     
  16. FloweryAF

    FloweryAF

    Joined:
    Sep 13, 2020
    Posts:
    13
    Hello! I might be having the same issue? I'm in 2020.3.17f1 and in the editor the FreeLook movement is maybe twice as fast. I've taken much of the advice above, changed to Input Value Gain and I've updated CM to 2.6.11, but here's an example, macOS and PC builds are (thankfully) the same, but in editor...
    https://www.dropbox.com/s/lgtkdapwup9txcg/Camera sensitivity demo.mp4?dl=0
     
  17. AlexStrook

    AlexStrook

    Joined:
    Oct 19, 2013
    Posts:
    31
    Hi, just to be sure, was this ever backported to 2.6.x? I'm having issue with my CM freelook cam, where the speed looks very different depending on framerate, even though I'm using "Input value gain" mode


    Thanks!
     
  18. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Yes it was. What version of CM are you using??
     
    Last edited: Jul 5, 2022
  19. AlexStrook

    AlexStrook

    Joined:
    Oct 19, 2013
    Posts:
    31
    Thanks for the reply, the problem was on my side!
    Turns out controlling the axis of the Freelook mouse vs. controller joystick required a lot more fine tuning that I expected!

    We can switch between Mouse and controller input on the fly in my game, and this was causing issue, I needed to process the input differently depending on the device used!
     
    Gregoryl likes this.