I’ve created a script to rotate the camera on the z axis in order to allow the player to look up and down while holding the arrow keys down. I want to make it so that when they release the key, only the z axis rotation is reset, but the only script I’ve gotten to come close to working resets all axes, which is disorienting and not at all what I want.
This is the current script to reset rotation upon release of the key:
if (rotatingVertically)
{
if (Input.GetKeyUp(KeyCode.UpArrow))
{
transform.rotation = Quaternion.identity; //resets rotation but resets all axes
rotatingVertically = false;
}
else if (Input.GetKeyUp(KeyCode.DownArrow)) //executes the first frame that the user releases the DownArrow
{
transform.rotation = Quaternion.identity; //resets rotation but resets all axes
rotatingVertically = false;
}
}