Setting Fire1 to rotate a game object every time i click

I am a total newb with scripting and unity, so please bear with me. I’m trying to make a memory game where I click on a card and it will turn over, so I’m practicing with a card-like cube, with this script:

 function Update () {
if(Input.GetButtonDown("Fire1")) {
transform.rotation = Quaternion.AngleAxis(90, Vector3.up);
}
}

How can I make the card turn 90 degrees every time I click?

An easy way would be to keep track of how much it’s rotated, and every time they click add 90 to it and then use that value in AngleAxis. I think you can also multiply the existing rotation by the new Quaternion to get the same result, but I’m not certain on that.

Take a look at other rotation questions:

  1. Rotate 90 over time on mouseDown - Questions & Answers - Unity Discussions
  2. rotate object when button is pushed - Questions & Answers - Unity Discussions