public IEnumerator Enter() { agent.destination = agent.transform.position; while (true) { light = aimanager.AssignMeALight(aiagent); if (light != null) { agent.destination = light.transform.position; while (agent.destination.XZ() != agent.transform.position.XZ()) { yield return(null); } } yield return(new WaitForSeconds(.5f)); aimanager.ReturnALight(aiagent); } }