# Unity Animator - bool transitions keep re-entering state while true

My StateMachine is triggered in a loop as long as transition boolean is true.

I have made sure my code only runs once, where I set the animation bool:

animator.SetBool("talk", true);


This does trigger the transition but the problem is that it re-triggers every frame as long as the bool is true. I had the same issue with a normal state earlier, but there I could turn off "Can transition to self" which solved it. However a StateMachine does not have that option.

I want the animation to play until the bool is set back to false, so using a trigger would not be good here.

EDIT: For some reason it seems the "Transition duration" is the one resetting my animation. So if I change that to 3, it re-enters every 3 seconds, and so on. This seems really weird?

How do I just make sure that the animation plays until its done, then it re-enters (to choose another random talking animation from my StateMachine), as long as talk == true?

• As you set animation from "Any state" and also i think "Has end" is set to false. so every time when bool is true it restart the animation. so i would suggest to use trigger instead of bool. This is just my assumption. Oct 11 '19 at 16:59
• @Swati I want the animation to loop several times until finished talking, so trigger wont really work. Oct 11 '19 at 17:03
• then make sure to set "Has End" to true. and exit time to 1. Oct 11 '19 at 17:06
• @Swati where are you getting "Has End" from? Oct 11 '19 at 17:07
• sorry it is not "Has End" it is "Has Exit time" sorry my mistake. Oct 11 '19 at 17:09