(Unity)ランダムに、時計回り・反時計回りに回転させる(コルーチンの活用)

(スクリプト)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RotateA : MonoBehaviour
{
    public GameObject target;
    private float speed;
    private float time;

    private void Start()
    {
        StartCoroutine(MoveManager());
    }

    void Update()
    {
        transform.RotateAround(target.transform.position, Vector3.up, speed);
    }

    // コルーチン
    private IEnumerator MoveManager()
    {
        while(true)
        {
            speed = Random.Range(0.5f, 3f);
            time = Random.Range(0.5f, 8.5f);

            yield return new WaitForSeconds(time);

            speed = Random.Range(-5f, -0.6f);
            time = Random.Range(0.5f, 3.5f);

            yield return new WaitForSeconds(time);
        }
    }
}

(実行結果)

・ランダムに時計回り・反時計回りを繰り返せば成功