Search Unity

Cinemachine Input Provider not working?

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

  1. DanielRiches

    DanielRiches

    Joined:
    Nov 23, 2019
    Posts:
    166
    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:
    856
    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.
     
    wesleywang likes this.
  4. DanielRiches

    DanielRiches

    Joined:
    Nov 23, 2019
    Posts:
    166
    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:
    856
    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:
    20
    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:
    856
    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:
    20
    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:
    20
    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:
    20
    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:
    856
    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: Feb 2, 2022
    DanielRiches likes this.
  12. naishtech

    naishtech

    Joined:
    Sep 21, 2018
    Posts:
    20
    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:
    20
    This appears to have been fixed by upgrading Unity's InputSystem to v1.2
     
  14. wesleywang

    wesleywang

    Joined:
    Sep 7, 2019
    Posts:
    5
    I have the same question. It seems that this problem is still not fixed....
     
  15. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    Is it possible that you have multiple action maps in play? By default, CinemachineInputProvider is set up to map to the DefaultInputActions asset that ships with the input system. If you're using a different input map, you should make sure that you set CinemachineInputProvider up with the correct actions.
     
  16. northman

    northman

    Joined:
    Feb 28, 2008
    Posts:
    144
    Hello, I got the same problem.
    Acording the tutorial video I make the new Input System with Cinemachine. Simply I just create a CinemachineFreeLook camera and set it Follow and LookAt to target. And plus Cinemachine Input Provider with the InputAction that I created.
    When I click the 'Play' button on the top of Unity, the FreeLook Camera doesn't work.

    These are the screenshots for my project:

    [Cinemachine FreeLook Camera]


    [It is the InputAction object I created]

    Could anybody please help me to figure out where I do the mistake settings on my project.
    Sincerely,
     
  17. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    The input actions are not enabled by default. You have to enable them.
    What version of Cinemachine are you using?
     
  18. northman

    northman

    Joined:
    Feb 28, 2008
    Posts:
    144
    Unity Version: 2021.2.17f1
    Cinemachine: 2.8.4
    Input System: 1.3.0
     
    Gregoryl likes this.
  19. SpectreCular

    SpectreCular

    Joined:
    Jan 15, 2015
    Posts:
    44
    I have a related issue where the Cinemachine Input Provider on my Cinemachine Virtual Camera is giving proper gamepad input values (via GetInputAxisProvider() and GetAxisValue()) but the camera itself isn't moving or orbiting around.

    It works fine if I use a different type of Cinemachine camera (or I believe with certain different Virtual Camera settings), but I got the proper setup and control just the way I like it with an ordinary Cinemachine Virtual Camera which I failed to achieve with the other built-in camera types.

    All I need is for the virtual camera to now respond to input, orbiting around the Follow Target when the player uses the Right Analog Stick. Would I need to subclass CinemachineVirtualCameraBase or something and perform the XY movement manually?

    Using:
    • Unity 2022.1.0b14.2951
    • Cinemachine 2.8.4
    • Input System 1.3.0
    My Settings:
    Screenshot_1.png Screenshot_2.png
    Input System's Update Mode is set to "Process Events in Dynamic Update"
     
    Last edited: Apr 15, 2022
  20. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    In the virtual camera's Body section, change Transposer to Orbital Transposer. The plain Transposer doesn't take user input.
     
  21. SpectreCular

    SpectreCular

    Joined:
    Jan 15, 2015
    Posts:
    44
    Thanks for the quick response!

    EDIT: Truncated post to start a new thread HERE, since it was starting to become unrelated to this thread.
     
    Last edited: Apr 17, 2022