Unity camera controls for mobile

1.1k Views Asked by At

What i want is the following:

  • I got an object in the scene (which will never move)
  • With the onSwipe on Mobile the camera should rotate around the object
  • With Pinch (two finger zoom-in or zoom-out) I want to zoom in/out to the object in the scene

So I tried it with cinemachine and made this works with a mouse. But what can I do to made this work with mobile input.

Here are my settings in CineMachine: enter image description here

And my CameraController.cs:

        if (Input.GetMouseButtonDown(0) || Input.touches.Any(x => x.phase == TouchPhase.Began))// kinda works, but its laggie
    {
        freeLookComponent.m_XAxis.m_MaxSpeed = 500;
    }
    if (Input.GetMouseButtonUp(0) || Input.touches.Any(x => x.phase == TouchPhase.Ended))// kinda works, but its laggie
    {
        freeLookComponent.m_XAxis.m_MaxSpeed = 0;
    }

    if (Input.mouseScrollDelta.y != 0) //and touch???
    {
        freeLookComponent.m_YAxis.m_MaxSpeed = 50;
    }
0

There are 0 best solutions below