public void decreaseLife(int degats) { // check si barbie die life = life - degats; if (life == -1) { SoundOnDie sod = GetComponent <SoundOnDie>(); if (sod != null) { GetComponent <AudioClipRandomizer>().StopAudio(); GetComponent <AudioClipRandomizer>().enabled = false; sod.Play(); } Destroy(GameManager.Instance.ambientMusic); _controller.enabled = false; _rigidBody.detectCollisions = false; _colider.enabled = false; StartCoroutine(LookAtDeath()); } else { SoundOnDommage sod = GetComponent <SoundOnDommage>(); if (sod != null) { GetComponent <AudioClipRandomizer>().StopAudio(); sod.Play(); } } }
IEnumerator DieCoroutine() { GetComponent <AbstractIAControler>().Stop(); GetComponent <MeshRenderer>().enabled = false; GetComponent <CapsuleCollider>().enabled = false; particleObject.SetActive(true); SoundOnDie sod = GetComponent <SoundOnDie>(); if (sod != null) { sod.Play(); } yield return(new WaitForSeconds(3f)); Destroy(gameObject); yield return(null); }