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) {
OpenDoor();
open = false;
}
}
void OpenDoor(){
anim.SetTrigger ("OpenDoor");
Invoke("CloseDoor",5);
}
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
thanks