How can I reset conditions for animations using an animation controller?

I have a door that will open when a boolean property in a script is set to true. This then calls setTrigger on the animator to play the open door condition and then reset the boolean property to false. After 5 seconds I then close the door. However when I change the boolean to true again to open the door, either the setTrigger isn't working again on the animator, or the trigger for the door close is conflicting. How would I resolve this? Is there a way in the animator to set a condition to false when a particular animation has finished? Initially I was using a boolean condition in the animator but ran into the same problem. I looked at the 2D sample project which used trigger instead and assumed this would only fire once. However I guess something else could be wrong. The code in my script is as follows: (where anim is the animator component)

   void Update(){
    if (open) {
        open = false;

void OpenDoor(){
    anim.SetTrigger ("OpenDoor");

void CloseDoor(){
    anim.SetTrigger ("CloseDoor");


As I say the animation fires correctly the 1st time but not on subsequent times. I'm just trying this by changing the public "open" property in the inspector



1 Answer 1


As per usual I worked out what was going wrong just after I answered the question! I had one of my old boolean conditions still attached to the transition from closing to an idle state. This never got evaluated so my close animation state was continuously running, although it wasn't on a loop. I just needed to change this to an exit time. This still seems a bit clunky to me so if anyone can provide a better approach I would be interested in hearing it


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .