Trouble adding to rotation.

This is supposed to make an object turn 90 degrees each time the player hits the right arrow key.
The outcome is that it makes it turn, until it hits 180 degrees, and then it doesn’t move at all. I don’t know whats wrong with my code.

if (Input.GetKeyDown("right")){
	selectionArea.transform.rotation.y +=   selectionArea.transform.rotation.y = 90.00 * Time.deltaTime;
	}

Hi Kidne,

You have to use Eular angels to perform such rotations (Although I would actually suggest you use Quaternions).

if (Input.GetKeyDown("right")){
     selectionArea.transform.rotation *= Quaternion.Euler(0,1 * Time.deltaTime,0);
     //Sorry I am not quite sure what you are trying to do with your function.
}

SO

you now understand that the rotation degrees is different then “180” or “90” or blah blah

it start from 0 ! to right is + and left is - ! (maybe not =D)

rotate your object and make a decision for adding number , like :

selectionArea.transform.rotation.y += 0.001

OR

selectionArea.transform.rotation.y += 0.05

or something else

and when it stop turning , like :

if(selectionArea.transform.rotation.y > -1) { selectionArea.transform.rotation.y -= 0.01 }

or

if(selectionArea.transform.rotation.y < 1) { selectionArea.transform.rotation.y += 0.01 }