Wait for a animation to finish in unity3d

I have a animation to play in update function in switch case.

after animation finish, a boolean get active

I written code as

case "play":    
              animation.Play("play");   
              gobool = true;
              startbool = false;
              break;

But works together.

How can i escape from this issue?

Thanks in Advance

if(animation.isPlaying)

or

if(animation.IsPlaying("myHappyAnimation")) 

first check if any animation is playing the second is a function that checks if the animation passed as parameter is playing

Try yield WaitForSeconds() and in that use the time which is taken by the length of your animation’s play…

animation.Play(“play”);
StartCoroutine(WaitAndCallback(animation[“play”].length));

in update function

IEnumerator WaitAndCallback(float waitTime){
yield return new WaitForSeconds(waitTime);
gobool = true;	  
}