Search Unity

CMFreelook via virtual joystick

Discussion in 'Cinemachine' started by piginhat, Aug 5, 2019.

  1. piginhat

    piginhat

    Joined:
    Feb 17, 2016
    Posts:
    96
    I have converted my app to Android and want to use one joystick to move the player and another to control the cmfreelook but am experiencing issues.

    I have removed the axis names from the cmfreelook script and in my update I have this:

    Code (CSharp):
    1.  void Update () {
    2.         cmfreeLook.m_XAxis.Value = UltimateJoystick.GetHorizontalAxis( "CameraJoystick" );
    3.        
    4.         fcmreeLook.m_YAxis.Value = UltimateJoystick.GetVerticalAxis( "CameraJoystick" );
    5.  
    6.     }
    7.  
    This does control the cmfreelook but very jittery in the vertical and nothing noticeable on the horizontal and I cannot replicate the response when simply using a finger to rotate/swivel the cmfreelook?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    Instead of doing that you should use the CinemachineCore.GetInputAxis() delegate. CM calls this whenever it needs axis input. Override it to call your UltimateJoystick methods.
     
    piginhat likes this.
  3. piginhat

    piginhat

    Joined:
    Feb 17, 2016
    Posts:
    96
    Thanks!

    Could you point me to an example? Im looking at the Cinemachine docs but not clear to me :-(
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
  5. piginhat

    piginhat

    Joined:
    Feb 17, 2016
    Posts:
    96
    BOOM! Thanks, works a charm. Totally understand how it works now...just could not figure it out!
     
    Gregoryl likes this.