Hi everyone.
I cant figure out how to make an AudioClip play when collecting coins.
I made coins to get Destroyed when pickeup and my AudioClip gets destroyed as well before it even gets a chance to play. Can someone help please.
var coinValue = 1;
var coinCollect : AudioClip;
function Update()
{
}
function OnTriggerEnter (col : Collider)
{
GameMaster.curGold += coinValue;
audio.Stop();
audio.PlayOneShot(coinCollect);
print(GameMaster.curGold); // Put some code in here
Destroy(this.gameObject);
}
If I change this.gameObject to col.gameObject then my pleyer gets destroyed and then I get audio to play.
How do I go around Destroy gameObject for to audio to play?
↧