Example #1
0
    IEnumerator Rotate()
    {
        if (!rotating)
        {
            rotating    = true;                 // set the flag
            targetRot.x = currentRot.x + 90.0f; // calculate the new angle

            while (currentRot.x < targetRot.x)
            {
                currentRot.x          = Mathf.MoveTowardsAngle(currentRot.x, targetRot.x, DegreesPerSecond * Time.deltaTime);
                transform.eulerAngles = currentRot;
                yield return(null);
            }
            rotating = false;
            if (currentColour != CubeColour.White)
            {
                currentColour++;
            }
            else
            {
                currentColour = CubeColour.Red;
            }
        }
    }
Example #2
0
 // Use this for initialization
 void Awake()
 {
     currentColour = CubeColour.Red;
 }