Play sound ONCE!

I need to trigger sound at the beginning of an action, and for it to play ONCE, and one time only. The thing is, I have all of my actions in an Udate function! I can't seem to force a sound clip to play through only one time- update keeps calling every frame. I cant link it to a coroutine either, because my intial commands are in Udate. I saw a post explaining something along the lines of using


but I can't seem to get it going. I've tried

}if (animation["attack"].time ==.1){

but that doesn't trigger it all.

I just need sound to play once on an action! Does any know of a work around? My models are from 3ds max, and and animation events seem over the top for something so simple. Thanks in advance!

To play a sound once at the beginning you could play it in the function Start() or set your AudioSource in the inspector to PlayOnAwake true, Loop false.

To play a sound once during Update() use a boolean variable or instantiate a GameObject with an AudioSource with the same settings.

function Start() {
  soundplayed = false;

function Update () {
  if (!soundplayed) {
    soundplayed = true;

Found a solution. I was close in my original attempt:

if(animation["x"].enabled && animation["x"].time == 0)
audio.clip = xsound;  

When you think about it, all sound clips are equal to zero at one point, so this will be a sure thing to check ONCE and one time during the life of the animation.

sourse code ( Unity - Scripting API: AudioSource.Play )

 public  AudioSource My_audio;

void Start(){
void Update{
if (distanse > 10) { My_audio.Pause (); }
if (distanse < 10) { My_audio.UnPause (); }