private IEnumerator MoveCooldown(Vector3 target) { Moving = true; /*A forma mais eficiente é rodar isso a partir da posicao do flash*/ Vector3 myPos = transform.position; List <Vector3> path = new Pathfinding2D(ground).A_Star(myPos, target); foreach (Vector3 NextPos in path) { if (player.transform.position != target) { path = new Pathfinding2D(ground).A_Star(myPos, target); } else { if (!flash.ilumina) { anim.SetBool("andando", true); Vector3 movVet = NextPos - transform.position; if (movVet.x > 0) { anim.SetFloat("horizontal", 1.0f); } if (movVet.x < 0) { anim.SetFloat("horizontal", -1.0f); } if (movVet.x == 0) { anim.SetFloat("horizontal", 0.0f); } if (movVet.y > 0) { anim.SetFloat("vertical", 1.0f); } if (movVet.y < 0) { anim.SetFloat("vertical", -1.0f); } if (movVet.y == 0) { anim.SetFloat("vertical", 0.0f); } transform.position = NextPos; //Move para a direção alvo. -A ms.PlaySound(Vector3.Distance(transform.position, player.transform.position)); yield return(new WaitForSeconds(Speed)); } else { anim.SetBool("andando", false); } } } Moving = false; }