I am making a horrorgame and want a sound to play when im passing a trigger. The problem is that it wont keeps being triggered every time I enter the trigger. What i want is to enter the trigger, play the sound, and then it has to never play again. I tried many things like destroying the clip.. but I cant seem to make it work properly.
public class SoundScript : MonoBehaviour
{
public AudioClip Snd_Sound;
IEnumerator Wait(){
yield return new WaitForSeconds(20000);
}
void OnTriggerEnter(Collider col)
{
audio.enabled = true;
audio.PlayOneShot(Snd_Sound, 1f);
StartCoroutine(Wait());
//???
}
}
Also it seems that my wait for second doesn't function.
Aucun commentaire:
Enregistrer un commentaire