Rotate object for a period of time

So I have a basic understanding of Java, but im new to javascript. So if you guys could help me out a bit, i want an object in this case a cube to rotate 180 degrees over a period of time.

So i use this basic command

function Update() {
transform.Rotate(0, 18 * Time.deltaTime, 0);
}

To rotate it 18 degrees every second. But i want the rotation to stop after 180 degrees, so i tried putting it into a loop but that didnt work.

So how should i do this, is this the best way or is there a smarter way?

Maybe try to use Ani.Mate (link: http://www.unifycommunity.com/wiki/index.php?title=AniMate), this seems to be suited for transform animation.

Also, check out the animation editor, new to Unity 2.6. This can help you do things that would previously have required time-based code.

I would suggest using the LERP and SLERP commands and quaternions.

Just give it a start point, target point, and a timeframe to do it and it will make a nice smooth animation from start to target over the alloted time.

L

i’ll try the different things to see which one works best.