Following on from an earlier question http://answers.unity3d.com/questions/8861/, my health decreases incrementally. As it does this the GUI health bar changes every time a multiple of 10 is reached (40, 30, 20...). I'd also like a sound to play each time it hits these markers. I tried to write a similar script as the one I have used to control the GUI, but it doesn't seem to work. Can you please tell me why? Thankyou!
var deathsound = AudioClip;
function update ()
{
if (HEALTH == 40) {
audio.PlayOneShot(deathsound);
}
else if (HEALTH == 30) {
audio.PlayOneShot(deathsound);
}
}
(Obviously I'd do this for each multiple of 10)
Could I also use this method to trigger an animation?