public override IEnumerator bootCoroutine(NPCController controller) { while (true) { yield return(WalkAround(controller, controller.Agent)); } }
// Use this for initialization void Start() { controller = GetComponent <NPCController>(); agent = GetComponent <NavMeshAgent>(); agent.speed = speed; //agent.SetDestination(waypoints[destinationPoint].position); }
protected IEnumerator WalkAround(NPCController controller, NavMeshAgent agent) { int destinationPoint = 0; controller = GetComponent <NPCController>(); //Circuit circuit = controller.GetComponent<Circuit>(); agent = GetComponent <NavMeshAgent>(); // Maybe, an IF instead of a while? List <Transform> waypoints = controller.GetComponent <Circuit>().Waypoints; if (waypoints == null || waypoints.Count == 0) { yield return(null); } else if (Vector3.Distance(waypoints[destinationPoint].position, transform.position) < 1) { destinationPoint = (destinationPoint + 1) % waypoints.Count; agent.SetDestination(waypoints[destinationPoint].position); } yield return(null); }
// Function to be Overrided on children public virtual IEnumerator bootCoroutine(NPCController controller) { yield return(null); }