How can I check if an animation has finished playing?

I am working on a jump → fall → land system. I want to determine when my landing animation has finished so that I can set my “landing” boolean to false. Here is the simple code:

// If the character is landing
			else if (landing) {
         		Debug.Log("Landing");
    	        animation[landingAnimation.name].wrapMode = WrapMode.Once;
    	      if(animation.clip.name!=landingAnimation.name || !animation.IsPlaying(landingAnimation.name) )
				animation.CrossFade(landingAnimation.name, 0.1f);  
			else
				landing = false;
				//falling = false;
				Debug.Log("Landing is false");
			}

As you can see, the landing animation is set to play once. I have commented out the boolean because otherwise it fires before the animation finishes. I have tried using !animation.isPlaying but it wasn’t working. Is there another way? Or maybe I haven’t set up the isPlaying correctly.

you are doing it right but seems like it is the problem of crossfading continuously inside the if loop, meaning the animation stays for ever!! change the code a bit it will be fine

/ If the character is landing
       else if (landing) {
         Debug.Log("Landing");

            animation[landingAnimation.name].wrapMode = WrapMode.Once;

          if(animation.clip.name!=landingAnimation.name  
                          ||  !animation.IsPlaying(landingAnimation.name) )
               animation.CrossFade(landingAnimation.name, 0.1f);  

           else
               landing = false;
       }

I hope this would work and also please bare me, if it has some typo, i couldnot test the code rite now!!