// Start is called before the first frame update void Start() { animator = gameObject.GetComponent <Animator>(); // Obtem Animator do inimigo bZWander = gameObject.GetComponent <BZWander>(); // Obtem script de perambular do inimigo SetAudioSources(); //PunchAudioSource.clip = PunchSound; }
// Corrotina que gerencia o ataque do inimigo public IEnumerator Attack() { while (true) { bZWander = gameObject.GetComponent <BZWander>(); // Recebe o script BZWander, que gerencia o modo de caminhar do inimigo bZWander.StopLazyWalkCoroutine(); // Chama uma função para encerrar a corrotina de perambular do inimigo animator.SetBool("Caminhando", false); // Para de executar a animção de andar animator.SetTrigger("Ataque"); // Aciona o trigger para executar a animação de atacar if (!PunchAudioSource.isPlaying) // Se o audio de golpe não está executando... { PunchAudioSource.Play(); // Execute o audio de golpe } if (attackSoundCoroutine != null) // Se a corrotina de som de ataque não iniciou... { attackSoundCoroutine = StartCoroutine(PlayAttackSound()); // Inicie a corrotina de som de ataque } yield return(new WaitForFixedUpdate()); // Aguarda o proximo FixedUpdate //yield return new WaitForSeconds(intervalAttack); //attackCoroutine = null; //bZWander.StartLazyWalkCoroutine(); yield return(null); // Retorna null, sinalizando o fim da corrotina } }