function Update () {
if (Input.GetButtonDown("Rotate")) {
transform.eulerAngles = Vector3(0,0,180);
}
}

How would I modify it so that the rotation occurs gradually over a set time that can be changed in the inspector? For example, if I want to rotate over two seconds, by the time it reaches two seconds it should be at 180 degrees.

Heya… you can add one variable and then make the rotation to be multiplied to (Time.deltaTime / the variable). Which means if you put 1 in the inspector the object will be rotated with 180 degrees per second, if you put 2, the Time.deltaTime will be divided by 2 and the object will be rotated with 180 degrees for 2 seconds… and so on…

Here’s the whole code…

// The number you add here in the inspector
// will be the number that the rotation will be divided.
public var rotationDivide : int;
function Update () {
if (Input.GetButtonDown("Rotate")) {
transform.eulerAngles += Vector3(0,0,180 * (Time.deltaTime / rotationDivide));
}
}