/// <summary> /// Walks towards the given destination /// </summary> /// <param name="destination"></param> /// <returns></returns> IEnumerator WalkRoutine() { curResourceAccessPoint = curResource.GetAccessPoint(ResourcesLow); state = State.Walking; navMeshAgent.SetDestination(curResourceAccessPoint.position); navMeshAgent.isStopped = false; ThoughtBubble.Thought thought = curThought; switch (curResourceType) { case Resource.Food: thought = ThoughtBubble.Thought.Food; break; case Resource.Water: thought = ThoughtBubble.Thought.Water; break; case Resource.Rest: thought = ThoughtBubble.Thought.Rest; break; } StartCoroutine(ShowThoughtBubbleRoutine(thought)); while (Vector3.Distance(navMeshAgent.destination, transform.position) > .01f) { yield return(new WaitForEndOfFrame()); } // Fully Stop navMeshAgent.velocity = Vector3.zero; yield return(new WaitForEndOfFrame()); // TODO: Change to smooth look at transform.LookAt(curResource.gameObject.transform); yield return(new WaitForEndOfFrame()); curResource.SetAccessPoint(curResourceAccessPoint); // Continue AutoChangeState(); }