- Home /
i have a error that can not play a disabled audio source
hello, I want to play the sound.
but, there is a error can not play a disabled audio source.
how can i fix it?
this is a my script.
private var destTime : float;
function Start () { destTime = 3.0; }
function Update () { destTime-=Time.deltaTime; if(destTime<=0.0) { Destroy(gameObject); } }
function OnTriggerEnter(other : Collider) {
if(other.gameObject.FindWithTag("Ball"))
{
gameObject.audio.volume = 100;
gameObject.audio.Play();
other.gameObject.FindWithTag("Refree").SendMessage("TimePlus",5);
Destroy(gameObject);
}
}
what's wrong whit this script?
i have no idea about this. please teach it to me.
Comment
Answer by SubatomicHero · May 14, 2013 at 07:02 AM
Try:
if (other.gameObject.FindWithTag("Ball"))
{
other.gameObject.audio.volume = 100;
other.gameObject.audio.Play();
...
...
}
Also do you maybe have a spelling mistake on this line?
other.gameObject.FindWithTag("Refree".SendMessage("TimePlus", 5);
Should the tag be "Referee"?.
Anyways hope this helps.