Hey guys,
So i am coding a simple way to moving the camera on android. However the camera is rotated and because of that when i slide my finger up it moves the camera in a diagonal way. How can i make it so i compensate that rotation and make it actually go up if i slide up? Here’s the code:
if (Input.touchCount == 1) {
Touch touchZero = Input.GetTouch (0);
Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition;
float deltaMagnitudeX = -(touchZeroPrevPos.x - touchZero.position.x) + Mathf.Sin(55);
float deltaMagnitudeZ = -(touchZeroPrevPos.y - touchZero.position.y) + Mathf.Sin(55);
Camera.main.transform.position = new Vector3(Camera.main.transform.position.x + ((deltaMagnitudeX * 0.01f)),Camera.main.transform.position.y,Camera.main.transform.position.z + (deltaMagnitudeZ * 0.01f));
}
PS: The camera’s rotation is 35,135,0