Search Unity

Question FreeLook Camera Rotation problem

Discussion in 'Cinemachine' started by Henryeah3D, Sep 13, 2022.

  1. Henryeah3D

    Henryeah3D

    Joined:
    Sep 2, 2022
    Posts:
    5
    Hello I'm using Cinemachine for a WebGL 3rd person game. I found freelook camera is very handy that it come with camera rotation by delta pointer. it work well in my WebGL Game so I can drag on my mobile screen to roate camera.
    but the problem is , I also use a virtual joystick for charactor movement. the camera will also rotate when I use the virtual joystick.
    I found a solution in youtube for not using cinemachine. that is, check the touch first, if it's on UI(joystick icon), the camera will not rotate. if it's not on UI element, the finger will rotate the camera.

    but for the case of using cinemachine, how could we achieve same logic?
    thanks!
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Cinemachine reads the input system by calling CinemachineCore.GetInputAxis(). This is a delegate which by default just calls Input.GetAxis(). You can install your own delegate that calls Input.GetAxis and preforms any additional logic before returning the value.

    Here is an example from another thread showing how to install a custom input delegate:
    https://forum.unity.com/threads/how...en-the-mouse-key-is-down.527634/#post-3468444