I am working on code that rotates the camera around a point on the in-game map when dragging the mouse. I understand how to lock it so it stays above the map surface.
However, if I keep rotating the view up, the camera will go "up and over" and be upside-down. How can I fix the camera orientation to make sure my camera stays upright?
A representative bit of code:
x += Input.GetAxis("Mouse X") * xSpeed; y -= Input.GetAxis("Mouse Y") * ySpeed; // when mouse moves left and right, rotate around local y axis transform.RotateAround(target.position,transform.up, x); // when mouse moves up and down, rotate around the local x axis transform.RotateAround(target.position,transform.right, y);