Camera with Key-Based Rotation Option

Hi everyone - I decided to make a few adjustments to the fixed camera that we were using at this point in the course…

First, I used Vector3.Lerp to smooth out the way that the camera follows the player.

Second, I wanted to have a way to rotate the camera without using the mouse. So, I connected up the Q and E buttons to rotate the camera left and right respectively.

For the camera rotation, I created a serialized field for CameraRotateSpeed (I found that a value of 20 works well). That said, you could just as easily adjust the float value in the Transform.Rotate Vector3 from 5f to something else and do without the CameraRotateSpeed.

Just wanted to add the code here in case this style of camera makes sense for your game. Hope you find it useful!

-Nathan

1 Like