amterp / COMP30019-Project-1

Project 1 for 2018 Semester 2 of COMP30019
1 stars 0 forks source link

Add camera rolling #23

Open amterp opened 6 years ago

amterp commented 6 years ago

Stretch goal.

Add simple camera rolling with Q/E.

amterp commented 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;