Open amterp opened 6 years ago
This seems to be a little harder than anticipated. There's a complication when implementing this as I have because, when the user rotates upside down, mouse movements become inverted. Not sure how to fix that, thought maybe some sin/cos stuff would work? I've tried transform.Rotate and Quarternion approaches to camera rotations, but none of them work as hoped.
Here's where I got with regular .localEulerAngles, which has the upside-down inversion problem:
// Determine how much, or if the user is trying to roll the camera with QE.
float rollAmount = Input.GetKey(KeyCode.Q) ? rollingSpeed : 0;
rollAmount += Input.GetKey(KeyCode.E) ? -rollingSpeed : 0;
// Translate those values and rotate the camera accordingly.
transform.localEulerAngles += new Vector3(-yRotationAmount, xRotationAmount, rollAmount) * Time.deltaTime;
Stretch goal.
Add simple camera rolling with Q/E.