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>();
     lvlSelector_A.onClick.AddListener(LevelSelector);

 }
 IEnumerator SlideLevelSelectMenu()
 {

     yield return new WaitForSeconds(1f);
     SceneManager.LoadScene("LevelSelectMenu");
 }

 void LevelSelector()
 {
     canvasAnim.SetBool("clickedclose", true);
     StartCoroutine(SlideLevelSelectMenu());
 }

Animator

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

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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