Ok I have kind of a problem that I’m sure there is a more elegant solution for than the one I’m using. I have a lot of voice clips that are accessed through numerous arrays like this. I’m currently using a coroutine for a few of the ones that just have one audio clip to add a little time onto the end of the Audio by setting a bool I call: KITT_SaidThis to true and then back to false about two seconds after the audio has completed, The reason for this is that I have a Voice recognition input that quite often thinks the Audio Clip responses are inputs, but I find if I add a little time after the response Audio then that seems to cure the problem. Like I say I’m accessing my response audio from numerous arrays like this.
public void BillyTheKiddFactoid(){
source.PlayOneShot (BillyTheKiddClips [Random.Range (0, BillyTheKiddClips.Length)]);
StartCoroutine (BTKvoiceBlocker ());
}
IEnumerator BTKvoiceBlocker(){
KITTmodesObject.KITT_SaidThis = true;
yield return new WaitForSeconds (12.5f); //Wait Time
KITTmodesObject.KITT_SaidThis = false;
}
//Parapsychology
public void ParapsychologyFactoid(){
source.PlayOneShot (ParapsychologyClips [Random.Range (0, ParapsychologyClips.Length)]);
StartCoroutine (PSvoiceBlocker ());
}
IEnumerator PSvoiceBlocker(){
KITTmodesObject.KITT_SaidThis = true;
yield return new WaitForSeconds (5.5f); //Wait Time
KITTmodesObject.KITT_SaidThis = false;
}
It works OK for these two as they are just single audio responses so I just looked at the Audio clip length in the inspector and then added on a little extra time for my KITT_SaidThis bool to be true, Which does the trick but on the other response arrays I have more than one response drawn randomly so unless I used a generic time delay there are times there would be too long a delay, if you catch my meaning.
I tried using an invoke method and using the audio length but strangely I found this did not work on the audio response clips that were 10 or so seconds long as the KITT_SaidThis bool would get activated to true but then at the end of the Audio response it would not go back to false. So the invoke method did not work in my case??