Rotate from angle to angle

Currently I am trying to code a ‘ping pong’ effect. I would like the object to start at angle 0, than rotate to angle 90, than rotate back to 0, etc…

What would be the easiest way to achieve this? Can I use Lerp? Any tips on an optimal setup would be great.

Thanks!

Strangely enough, Mathf.PingPong is really good for ‘ping pong’ effects. :wink:

var rotateSpeed = 50.0;

function Update () {
    transform.rotation = Quaternion.Euler(0.0, Mathf.PingPong(Time.time * rotateSpeed, 90.0), 0.0);
}