- Home /
How actions in if() are carried out depending on booleans?
Say there is an if(playAnimation) {// Play animation} Boolean playAnimation is set to true in one line of code, and the line that follows sets it to false, will the entire animation still play one time? Or will it just stop mid animation?
Answer by Taschenschieber · Jun 29, 2014 at 10:01 AM
The animation will only be played when playAnimation is true when the if clause is called. So, if you write
playAnimation = true;
playAnimation = false;
no animation will be played. But with
playAnimation = true;
if(playAnimation) {
// animation stuff goes here
}
playAnimation = false
the animation would be played.
Note that Unity scripts are executed one after another, they do not run at the same time.
Thank you for the response, I fixed it with a couple of IsActionCompleted style booleans, for I'm working with controller Input, an Get$$anonymous$$eyDown for a keyboard returns a keypress once, while a custom controller streams that a button was pressed. $$anonymous$$inda complicated and newbie-ish at the same time. Thank you though! :))
Your answer
![](https://koobas.hobune.stream/wayback/20220613152800im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to make an if command check a bool (or any other variable) only if it has changed 1 Answer
Why does Unity mean with :Cannot implicitly convert type `void' to `bool' ? 3 Answers
What am I doing wrong with this bool? 3 Answers
Update function is not executing the bool 1 Answer
How to make a file run if a void has undefined coordinates? 1 Answer