Unity

[Unity] Touch로 카메라 움직이기(Mobile)

Guk-blog 2019. 8. 29. 17:13
728x90
반응형
#elif UNITY_ANDROID
        if (Input.touchCount > 0)
        {
            if (Input.GetTouch(0).phase == TouchPhase.Began)
            {
                FirstPoint = Input.GetTouch(0).position;
                xAngleTemp = xAngle;
                yAngleTemp = yAngle;
            }
            if (Input.GetTouch(0).phase == TouchPhase.Moved)
            {
                SecondPoint = Input.GetTouch(0).position;
                xAngle = xAngleTemp + (SecondPoint.x - FirstPoint.x) * 180 / Screen.width;
                yAngle = yAngleTemp - (SecondPoint.y - FirstPoint.y) * 90  / Screen.height;
 
 
                this.transform.localRotation = Quaternion.Euler(yAngle, xAngle, 0.0f);
            }
        }      
#endif

 

728x90
반응형