Cannot get animation to play until finish without holding down the button

Hi there,

Have a little problem with playing animations and CoRoutines....

When I press the applicable key, the character is suppose to taunt, but the animation does not completely play.

Have a script for my character to taunt as follow:

function COtaunt () {
 var state : AnimationState = animation[taunt1];
 animation.Play("taunt1");
 yield new WaitForSeconds (state.lenght);
 animation.CrossFade("idle");
 }

function Update () {
 if (Input.GetButtonDown("Fire1")) {
   StartCORoutine("COtaunt");
   }
 }  

But, the CoRoutine does not complete, it only plays the first few frames (aprox 3) of the animation. I changed the Input.GetButtonDown to Input.GetButton, and it works, only problem is that you are not suppose to hold the key down to do the taunt. You must press it once, and then the animation must play.

I even tried to do:

function Update () {
  if (Input.GetButtonDown("Fire1")) {
    animation.Play("taunt1");
  }

But the animation still does not complete.....

I'm sure that I'm missing something simple, but tried all I could find in the Scripting Reference which I know about, and nothing fixed this.

Also, I want to block any other animations while its playing, and found the following:

private var InTransition : boolean = false;

and in the CORoutine I tried:

InTransition = true;

at the beginning, and at the end:

InTransition = false;

but it does not work. Aren't I suppose to add something to actually do something when the boolean is true?

Any ideas would be appreciated :)

have you tried to set the animation to play once by changing the wrap mode

animation[“taunt1”].wrapMode = WrapMode.Once