I want the audio on my gameobject, once played, to be disabled for a certain time, then enabled again. How can I do that?
you can use invoke to wait to call a function for a delayed period of time
invoke(audio.play,5f);
that will play the audio if 5 seconds.
using that you can go
PlayMusic(5);
void PlayMusic(int delay){
audio.play;
if(KeepPlaying)
{
invoke(PlayMusic(delay),delay);
}
}
now once you call play music it will keep calling PlayMusic every delay seconds until you make KeepPlaying false.
this function would be part of a class and the KeepPlaying would be outside the function so you can modify it to cancel the infinite loop.