- Home /
Cant repeat Sound
So i made an Entertrigger Exittrigger sound system where i can walk into a triggered collider and it will play sound while i'm in that collider and stop when i leave the collider. The problem i'm having is that i can only play the audio clip once and when i tried to change it to repeat it wouldnt work saying
Assets/GameObjects/HomemadeScripts/SOundCry.js(21,19): BCE0023: No appropriate version of 'UnityEngine.AudioSource.Play' for the argument list '(UnityEngine.AudioClip)' was found.
Can someone please tell me where i'm going wrong?
here's the code
#pragma strict
var flushClip:AudioClip;
var isFlush = false;
function OnTriggerEnter(o:Collider){
Debug.Log("The trigger fired enter");
isFlush = true;
if(isFlush == true){
playFlush();
}
}
function OnTriggerExit(o:Collider){
Debug.Log("The trigger fired");
}
function playFlush(){
audio.Play(flushClip);
isFlush = false;
}
Thanks in advance :)
Answer by BiG · Jun 18, 2013 at 08:56 AM
The error ("no appropriate version of [...] for the argument list [...]") states that you are invoking a function with the wrong type or number of parameters. In fact, audio.Play() doesn't take, as a parameter, the name of the audio track (it takes only the eventual delay, at which reproducing the sound).
You should do:
audio.clip = flushClip;
audio.Play();