wait until animation finish

so, i runed into a problem … i need to set a variable to true, then play an animation, and while the whole animation plays… the var needs to stay true, only when the anim is over, the var goes false… so i did this on my code

landingsequence = true;
animation.Play("land"); 
landingsequence = false;

nut what hapens is that the var toogles into true and then goes back to false in question of secounds… its not waiting til the animation “land” to end… but the way i placed the animation in the midle of true and false should make the script undestand that its supose to wait… right?.. well…

is there any if statement i can do?

… like…

if (animation “land” finish ) { landingsequence = false; }

else { do nothing }

or something like that? … if there is can someone post an example of how the code would look like?

void Update() {
    if (animation.IsPlaying("land")) {
        landingSequence = true;
    }
    else {
        landingSequence = false;
    }
}

the if statement works great thanks!

but i had to take out this void thing… evertime i put this void in the midle of my script… he aways keeps whining about missing semicollon ; or something like that…

That’s because “void Update” is a function, so it probably won’t work inside of another function. A void is a function that returns/gives you back nothing at the end of it’s runtime, if I’m correct :smile:

He’s probably using javascript

You can also use the yield function for this:

yield return WaitForSeconds(animation["land"].length);