Rotation Control

For some reason when ever I click rotate Left or right the rotation just snaps to 180 instead of increasing/decreasing by 90.

var rotations : float[] = [0f,90f,180f,270f];
var currentRot : int = 0;

var currentAngle : float = 0;
var targetAngle : float;
var rotateTime : float = 1;
private var rotateVelocity : float = 0;

Later(In update Loop):

if(Input.GetButtonDown("RotateRight"))
	currentRot += 1f;

if(Input.GetButtonDown("RotateLeft"))
	currentRot -= 1f;

if(currentRot > 3f)
	currentRot = 0f;
if(currentRot < 0f)
	currentRot = 3f;

targetAngle = rotations[currentRot];
currentAngle = Mathf.SmoothDampAngle(currentAngle,targetAngle,rotateVelocity, 0.2);
transform.rotation.y = currentAngle;

Instead of modifying the Quaternion, you can modify transform.eulerAngles, but the script reference has this warning:

Do not set one of the eulerAngles axis separately (eg. eulerAngles.x = 10; ) since this will lead to drift and undesired rotations. When setting them to a new value set them all at once.

So you need to keep your own Vector3 for all three angles, and then set the all at once. But there is another issue here. The reference page does makes no mention of SmoothDampAngle() handling the 0/360 boundry, so when you go from 270 to 0, it will likely rotate the long way around.

Here is some alternate code for doing 90 degree rotations. Note I changed the input to GetMouseButtonDown(). I’m not sure what was important about your original code, so this may not be what you want.

var targetAngle : float = 0.0;
var rotateSpeed : float = 10.0;

var qTo : Quaternion;

function Start() {
  qTo = Quaternion.identity;
  transform.eulerAngles = Vector3.zero;
}

function Update() {

if(Input.GetMouseButtonDown(0)) {
    targetAngle += 90.0;
    qTo = Quaternion.Euler(Vector3(0,targetAngle,0));
    }
    
if(Input.GetMouseButtonDown(1)) {
	targetAngle -= 90.0;
	qTo = Quaternion.Euler(Vector3(0,targetAngle,0));
}
 
transform.rotation = Quaternion.Slerp(transform.rotation, qTo, rotateSpeed * Time.deltaTime);
}