sound buzzing enemy dies
sound is buzzing when enemy dies but when pause is shortened sound is played too quick
var EnemyHealth : int = 10; var soundFile : AudioClip; function DeductPoints (DamageAmount : int) { EnemyHealth -= DamageAmount; } function Update () { if (EnemyHealth <= 0) { GetComponent.().clip = soundFile; GetComponent.().Play(); Destroy(gameObject, 1); }
}
Answer by hameed-ullah-jan · Oct 31, 2018 at 06:17 AM
Try this code it is your code, but I did a lil modification: bool once = true; var EnemyHealth : int = 10; var soundFile : AudioClip; function DeductPoints (DamageAmount : int) { EnemyHealth -= DamageAmount; } function Update () { if (EnemyHealth <= 0) { GetComponent.().clip = soundFile; if(once) { GetComponent.().Play(); once = false; } Destroy(gameObject, 1); } }
Your answer
Follow this Question
Related Questions
UNITY shooting script does nothing 1 Answer
Problem with boat script 0 Answers
How do I get my enemy to flip to face the direction he is moving? 3 Answers
Why is this script not working? 2 Answers
Basic FPS help! 2 Answers