How do I call audio once when conditions are met?

I need an audio clip to play once every-time the player gets to far from his base. The problem is if it's in an update function then it happens several times and if it's in a start or awake function it only happens at the start of the game. What's the proper way to get it to call once every time the conditions are met?

You can either put a conditional in an `Update()` which wouldn't be too hard.

You could use InvokeRepeating to decrease the frequency which you check:

var frequency = .5;
//Check every half second.

function Start () {
    InvokeRepeating("CheckPlayerDist", frequency, frequency);
}

function CheckPlayerDist() {
     if(PlayerDistance > someDistance) {
         audio.PlayOneShot(someSound);
      }
}

or you could put a large trigger around your base and then play a sound when the player leaves it:

function OnTriggerExit(col : Collider) {
     if(col == player) {
          audio.PlayOneShot(someSound);
     }
 }