IEnumerator _Rotate(float angle) { float waitTime = DistanceToLeader / _swim.Speed; float elapse = 0; while (elapse < waitTime) { elapse += Time.deltaTime; yield return(0); } _swim.Rotate(angle); }
void Update() { if (ElapseRotate > TimeRotate) { _swim.Rotate(Random.Range(-RotateAngleRndRange, RotateAngleRndRange)); ElapseRotate = 0; TimeRotate = RotateInterval + Random.Range(-RotateIntervalRndRange, RotateIntervalRndRange); } else { ElapseRotate += Time.deltaTime; } }