How to rotate the camera on a button press.

Ok, so i’m trying to make my camera rotate one i press the F button, here’s my code that doesn’t seem to be working, upon pressing play the camera is constantly spinning.
#pragma strict
var Flipping = false;

function FlipTimer()
{
Flipping = true;
WaitForSeconds(3);
Flipping = false;
}

function CheckFlip () {
if (Input.GetAxis ("f")){
Invoke("FlipTimer" ,0);
}
}


function Update () {
if (Flipping === true){
transform.Rotate(Vector3.left*9);
}
}

Ideally, i was hoping pressing the button “f” would set the flipping varriable to true, with the if statement in the function update checking to see if this was true. If so it would rotate.

Hi frosstt, try using GetKeyUp which will register your f keyboard press after you release it, and without testing your code, this is going to make your camera spin for 3 seconds then stop.

If you want it to turn only when you press f, check out implementing GetKeyDown into your code.
If you want to do this try

Function Update()
{
  If (Input.GetKeyDown(KeyCode.F))
    Transform.Rotate(Vector3.left*9);
}

thanks to @hellaeon. i used

function Lateupdate()
 {
if(Input.GetKey(KeyCode.F))
{
transform.Rotate(new Vector​3(0.0f, 5.0f, 0.0f));
}
 }

This rotates the Y-Axis camera