How to move Cinemachine FreeLook camera with touch input?

I’ve recently installed Cinemachine and I am trying to use a FreeLook virtual camera. The FreeLook camera is not responding to my touch input when I run in Unity remote.

When I tried writing a script to control the virtual camera transform.position based on touch input, the virtual camera did not change position but instead stayed locked to the offset set up in the component.

Does anyone have a solution for working with touch input and Cinemachine virtual cameras?

Thank you.

Hi,

You need to implement the GetInputAxis delegate:

  CinemachineCore.GetInputAxis = HandleAxisInputDelegate;

here is a working Component that works, simply drop it on any GameObject in your scene:

you can also get it on the PlayMaker Ecosystem or github, more info here: https://twitter.com/JeanAtPlayMaker/status/978915559994740736

using Cinemachine;
using UnityEngine;


public class CinemachineCoreGetInputTouchAxis : MonoBehaviour {

    public float TouchSensitivity_x = 10f;
    public float TouchSensitivity_y = 10f;

	// Use this for initialization
	void Start () {
        CinemachineCore.GetInputAxis = HandleAxisInputDelegate;
	}
	
    float HandleAxisInputDelegate(string axisName)
    {
        switch(axisName)
        {

            case "Mouse X":

                if (Input.touchCount>0)
                {
                    return Input.touches[0].deltaPosition.x / TouchSensitivity_x;
                }else{
                    return Input.GetAxis(axisName);
                }

            case "Mouse Y":
                if (Input.touchCount > 0)
                {
                    return Input.touches[0].deltaPosition.y / TouchSensitivity_y;
                }
                else
                {
                    return Input.GetAxis(axisName);
                }

            default:
                Debug.LogError("Input <"+axisName+"> not recognyzed.",this);
                break;
        }

        return 0f;
    }
}

Bye,

Jean

You are too good