Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

Cinemachine Input Provider not working?

Discussion in 'Cinemachine' started by DoomPriestK, Oct 25, 2021.

  1. DoomPriestK

    DoomPriestK

    Joined:
    Nov 23, 2019
    Posts:
    126
    Using Cinemachine 2.8.1
    Using Input System 1.1.1
    Using HDRP 12.0.0

    I have the New Input System selected in preferences.

    These are my settings:

    upload_2021-10-25_1-16-5.png

    I have also tried Passthrough instead of value, I ramped up the speed in case that was the issue but it doesn't seem to be.

    The following code is in Awake:
    upload_2021-10-25_1-19-21.png

    Which links to this:
    upload_2021-10-25_1-20-7.png

    Using this it clearly reads the Input value just fine
    upload_2021-10-25_1-18-46.png

    Curiously yesterday this was actually working fine using Value, today it doesn't seem to work at all....

    Does anyone have any insight as to why?
     
    Last edited: Oct 25, 2021
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    583
    It is very difficult to say. On my side, the input works.
    Did something change since yesterday when it was working?
     
  3. tomwilhelm

    tomwilhelm

    Joined:
    Nov 12, 2018
    Posts:
    1
    I'm having a similar issue. I noticed this when I updated my project from Unity 2021.1.25 to 2021.2.0. CinemachineInputProvider seems to track the values correctly until I press a button associated with a different input action. I am also using a PlayerInput component which might be related.
     
  4. DoomPriestK

    DoomPriestK

    Joined:
    Nov 23, 2019
    Posts:
    126
    Curiously I upgraded the engine version as tomwilhelm posted above, that's the only difference as far as I know
     
  5. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    583
    I could not reproduce the issue with this setup:
    Unity version 2021.2.0f1
    Using Cinemachine 2.8.1
    Using Input System 1.1.1
    Using HDRP 12.0.0

    Could you submit a bug report with a repro project please?
     
  6. naishtech

    naishtech

    Joined:
    Sep 21, 2018
    Posts:
    13
    I'm getting exactly the same problem - the only thing that fixed it in the Play Mode Editor, was to change the Update Mode in the Input System settings to "Process Events in Fixed Update". Unfortunately once I build the project the camera then is jerky when rotating freelook or zooming. I've tried a few settings in the CinemachineBrain to try and fix it, but to no avail.

    input_cinemachine.png

    Edit: Using:

    - Editor 2021.2.0
    - Input 1.1.1
    - Cinemachine 2.8.2
     
    gaborkb likes this.
  7. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    583
    Could you submit a bug report with a repro project or send me a direct message with your project please?
     
  8. naishtech

    naishtech

    Joined:
    Sep 21, 2018
    Posts:
    13
    Hi I've spent the morning trying to reproduce with a new project but can't.

    Perhaps an upgrade from an old project to 2021.2.f1 might cause it?

    I'm going to try and reimplement the PlayerInput again and see what happens.
     
  9. naishtech

    naishtech

    Joined:
    Sep 21, 2018
    Posts:
    13
    Ok so the best I can do is share these logs with you.

    I have added the following debug statements in LateUpdate in a Script on my CinemachineFreeLookCamera

    Code (CSharp):
    1.  
    2. public void LateUpdate()
    3.     {
    4.    
    5.         Debug.Log($"YAxis Value {cinemachineFreeLook.GetInputAxisProvider().GetAxisValue(1)} " +
    6.             $"YAxis InputValue {cinemachineFreeLook.m_YAxis.m_InputAxisValue}");
    7.  
    8.     }
    The logs before I press a button associate with another action event are as follows:

    "YAxis Value 1 YAxis InputValue 0"
    "YAxis Value 3 YAxis InputValue 1"
    "YAxis Value 1 YAxis InputValue 3"
    "YAxis Value 3 YAxis InputValue 1"

    and so on...

    The logs after I press a button associate with another action event are as follows:

    "YAxis Value 3 YAxis InputValue 0"
    "YAxis Value 2 YAxis InputValue 0"
    "YAxis Value 1 YAxis InputValue 0

    As you can see the "cinemachineFreeLook.GetInputAxisProvider().GetAxisValue(1)" call is returning the correct value, but after I press a key associated with another input action "cinemachineFreeLook.m_YAxis.m_InputAxisValue" is always 0.
     
    Last edited: Nov 5, 2021
  10. naishtech

    naishtech

    Joined:
    Sep 21, 2018
    Posts:
    13
    So I have found a temporary fix - I set the CinemachineBrain's update method to "Manual" and then called Cinemachine.ManualUpdate() in the LateUpdate method of a script attached to the freelook virtual camera.

    Code (CSharp):
    1.  
    2.  
    3. [SerializeField] private CinemachineBrain cinemachineBrain;
    4.  
    5. public void LateUpdate()
    6.     {
    7.         DoAnyVCamUpdates();
    8.  
    9.         cinemachineBrain.ManualUpdate();
    10.    }
    Interestingly, even doing this in the LateUpdate method didn't work

    Code (CSharp):
    1. AxisState.IInputAxisProvider inputAxisProvider = cinemachineFreeLook.GetInputAxisProvider();
    2. AxisState m_XAxis = cinemachineFreeLook.m_XAxis;
    3. m_XAxis.m_InputAxisValue = inputAxisProvider.GetAxisValue(0);
     
  11. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    583
    We could reproduce the issue, and are investigating with the Input System team.

    A temporary fix, this should not be necessary, when the issue is fixed:

    Your input might not be working, because it is not processed in the same update loop as CinemachineBrain's Update method.

    In Edit > Project Settings > Input System Package, change the Update method.

    Check, which Update Method CinemachineBrain is using, and set the input to the same.
    • If CinemachineBrain is in Late Update, then set Dynamic Update for inputs.
    • If CinemachineBrain is in Fixed Update, then set Fixed Update for inputs.
    CmBrainUpdate2.png InputUpdate.png

    Here is a summary of what each update mode means in CinemachineBrain:
    • FixedUpdate: Virtual cameras are updated in sync with the Physics module.
      Use FixedUpdate if all your targets are animated with for RigidBody animation
    • LateUpdate: Virtual cameras are updated in MonoBehaviour LateUpdate.
    • SmartUpdate: Virtual cameras are updated according to how the target is updated.
    • ManualUpdate: Virtual cameras are not automatically updated, client must explicitly call.
     
    Last edited: Nov 12, 2021
    DoomPriestK likes this.
  12. naishtech

    naishtech

    Joined:
    Sep 21, 2018
    Posts:
    13
    Thanks @gaborkb Good to hear you have reproduced it.

    I have tried both the Late Update and Dynamic Update settings you suggested and they both work, however they don't produce as smooth freelook camera as having Input Settings set to "Process Events in Dynamic Update" and CinemachineBrain's update method set to "Smart Update".

    In the meantime I have just implemented some editor directives as this doesn't seem to happen when I build the project.
     
    gaborkb likes this.
  13. naishtech

    naishtech

    Joined:
    Sep 21, 2018
    Posts:
    13
    This appears to have been fixed by upgrading Unity's InputSystem to v1.2
     
unityunity