private IEnumerator SetDestinationRoutine(Object target) { //get references UnityEngine.AI.NavMeshAgent agent = GetComponent <UnityEngine.AI.NavMeshAgent>(); navMove myMove = GetComponent <navMove>(); GameObject tar = (GameObject)target as GameObject; //increase agent speed myMove.ChangeSpeed(4); //set new destination of the navmesh agent agent.SetDestination(tar.transform.position); //wait until the path has been calculated while (agent.pathPending) { yield return(null); } //wait until agent reached its destination float remain = agent.remainingDistance; while (remain == Mathf.Infinity || remain - agent.stoppingDistance > float.Epsilon || agent.pathStatus != UnityEngine.AI.NavMeshPathStatus.PathComplete) { remain = agent.remainingDistance; yield return(null); } //wait a few seconds at the destination, //then decrease agent speed and restart movement routine yield return(new WaitForSeconds(4)); myMove.ChangeSpeed(1.5f); myMove.moveToPath = true; myMove.StartMove(); }
// Token: 0x060006F0 RID: 1776 RVA: 0x0002D688 File Offset: 0x0002BA88 private IEnumerator SetDestinationRoutine(UnityEngine.Object target) { NavMeshAgent agent = base.GetComponent <NavMeshAgent>(); navMove myMove = base.GetComponent <navMove>(); GameObject tar = (GameObject)target; myMove.ChangeSpeed(4f); agent.SetDestination(tar.transform.position); while (agent.pathPending) { yield return(null); } float remain = agent.remainingDistance; while (remain == float.PositiveInfinity || remain - agent.stoppingDistance > 1.401298E-45f || agent.pathStatus != NavMeshPathStatus.PathComplete) { remain = agent.remainingDistance; yield return(null); } yield return(new WaitForSeconds(4f)); myMove.ChangeSpeed(1.5f); myMove.moveToPath = true; myMove.StartMove(); yield break; }