Search Unity

Camera not rotating when swiping on screen

Discussion in 'Getting Started' started by unity_D62LVB06TAmo5w, Nov 7, 2022.

  1. unity_D62LVB06TAmo5w

    unity_D62LVB06TAmo5w

    Joined:
    Apr 24, 2020
    Posts:
    1
    0
    I am developing a game with Unity using 3D Game Kit. I am having issues with the camera. When I placed a canvas to add a joystick in order to move the player, the camera stopped responding to swipes on the screen, it only points to a specific direction. I am using m_Camera.Set() to set directions on swipe but it is not working. Using mouse m_Camera.Set(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); for desktop works fine, but I want to make this work for mobile devices too.

    This is how I am trying:

    Code (CSharp):
    1.  
    2. if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
    3. {
    4.        Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
    5.        m_Camera.Set(touchDeltaPosition.x, touchDeltaPosition.y);
    6.        Debug.Log(m_Camera.x);
    7.  
    8.    }
    The log displays different values but camera does not move.