/// <summary> /// 行動する /// </summary> /// <param name="callBack"></param> /// <returns></returns> public virtual IEnumerator Action(UnityAction callBack) { enemyAnimation.StartRunAnimation(); agent.SetDestination(movePosition); agent.isStopped = false; isDetectPlayer = false; //目的地に戻るまで while (!IsMoveEndCondition()) { //移動中にプレイヤーを見つけたら終了する if (IsDetectPlayer()) { isDetectPlayer = true; Finish(callBack); yield break; } yield return(new WaitForSeconds(Slow.Instance.DeltaTime())); } enemyAnimation.StopRunAnimation(); agent.isStopped = true; //角度が違っていたら回転する float time = 0.0f; Quaternion beforeRotation = topTransform.rotation; while (!IsRotateEndCondition()) { //回転中にプレイヤーを見つけたら終了する if (IsDetectPlayer()) { isDetectPlayer = true; Finish(callBack); yield break; } time += Slow.Instance.DeltaTime(); topTransform.rotation = Quaternion.Slerp(beforeRotation, moveRotation, (time / rotateSecond)); yield return(new WaitForSeconds(Slow.Instance.DeltaTime())); } Finish(callBack); }