Yield conflict with audio => distortion
Ok, my problem is that when I give a value greater than 0f in waitforseconds it's distorting my sound/audiofile. . If yeld it 's 0 it works properly but enemy is destroyed and does not have enough time to show animation. Sorry for my bad english. What I must do? I'm in a hurry because I want to release this game in 2 days. void Start () { anim = GetComponent (); audio = GetComponent (); }
// Update is called once per frame
void Update () {
if (enemyHealth <= 0) {
offset = player.transform.position;
//Instantiate (deathEffect, transform.position, transform.rotation);
anim.SetBool ("Imp", true);
ScoreManager.AddPoints (pointsonDeath);
//AudioSource.PlayClipAtPoint (death, offset, 0.7f);
verifica = true;
StartCoroutine (KillOnAnimationEnd ());
} else {
anim.SetBool ("Imp", false);
offset = player.transform.position;
}
}
public void giveDamage(int damageToGIve)
{
enemyHealth -= damageToGIve;
}
private IEnumerator KillOnAnimationEnd() {
AudioSource.PlayClipAtPoint (death, offset, 0.7f);
yield return new WaitForSeconds (0.4f);
Destroy (gameObject);
}
Answer by metalamen96 · Dec 21, 2016 at 05:56 PM
Someone can help me please? If i don;t resolve this quickly I will be forced not to use death animation.Thanks
Your answer
Follow this Question
Related Questions
Why are our pixels changing shape and size randomly in our 2D pixel game? 0 Answers
How to get my Player Death Sound To Stop Playing? 1 Answer
Chromatic aberration effect on collision or trigger,Chromatic aberration on collision or trigger 1 Answer
Sprite Deforms/Change Scale itself on Collision 1 Answer
Big sprite textures with animations appears distorted and flickers, only in build. 2 Answers