Hey
I want to pick up a coin, and then play a sound.
But as it is right now, i playes the sound and then destroys the coin.
Is there any way to destroy the coin and play the sound at same time, so that the coin disapear immediatly and the sound starts when the coin disapears and plays until it’s finished
#pragma strict
var coinValue : float;
var MoneySound : AudioClip;
function Start () {
if (Application.loadedLevelName == "Stibro")
{
coinValue = 1;
}
else if (Application.loadedLevelName == "Musik - og Teaterhus")
{
coinValue = 2;
}
else if (Application.loadedLevelName == "Odense Havn")
{
coinValue = 5;
}
else if (Application.loadedLevelName == "Letbane")
{
coinValue = 10;
}
else if (Application.loadedLevelName == "Nyt OUH")
{
coinValue = 10;
}
}
function OnTriggerEnter (info : Collider){
if (info.tag == "Player")
{
if (GameObject.FindGameObjectWithTag("Coin")){
GameMaster.currentScore += coinValue;
Destroy(gameObject);
audio.pitch = 0.85;
audio.clip = MoneySound;
audio.Play();
yield WaitForSeconds (audio.clip.length);
}
}
}