private IEnumerator MoveTo() { while (!selfRoleController.IsGrounded()) { yield return(null); } var selfPos = selfRoleController.transform.position; var targetPos = targetRoleController.transform.position; var path = roleNavMeshAgent.CalculPath(targetPos); if (path.Length <= 0) { Debug.LogError("path为空!"); } for (int currIndex = 1; currIndex < path.Length; currIndex++) { var position = path[currIndex]; IEnumerator moveTo = roleBehaviorTree.MoveTo(position, selfRoleController.GetSpeedByMoveState(MoveState.Walk)); while (true) { if (moveTo.MoveNext()) { yield return(CoroutineStatus.Running); } else { break; } } } }