I want to do menu animation. In the animator, its contain 2 animations. One is opening animation, the other is closing animation. I set the opening animation as default state and added condition between of them. The condition contains one parameter, it is a bool type parameter. I drag the script which controls they behaviours on gameobject and animator component, but when the opening animation plays and player clicks the play button the parameter turns into true but it doesn't play.

 Animator canvasAnim;

 public Button lvlSelector;
 Button lvlSelector_A;

 // Use this for initialization
 void Start () {
     canvasAnim = GetComponent<Animator>();

     lvlSelector_A = lvlSelector.GetComponent<Button>();

 IEnumerator SlideLevelSelectMenu()

     yield return new WaitForSeconds(1f);

 void LevelSelector()
     canvasAnim.SetBool("clickedclose", true);


Gameobject that keeps script component


Maybe you should add your onClick method as an AnimationEvent after the MainMenuClosing animation finishes. Animation Events allow you to add data to an imported clip which determines when certain actions should occur in time with the animation.enter image description here

(Sorry couldn't post this as a comment)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.