- Home /
When click on a button, play an animator animations through booleans
Hello people. I'm doing a 3d menu with animations between panels, and I have an animator for the camera to move between different panels. For example: From the main menu to the level selector. I had thought of doing it with an animator component and booleans in the animator, to move from one animation to another, and since the inspector works, but of course, I want to do it through UI buttons, which, through a script, but I didnt find the method to do that the booleans be changed through the script. If you know how to do it, please help me. Thank you.
(Sorry if my english its not very good U_u)
Answer by FallingRocketGames · Sep 30, 2017 at 12:17 PM
First you have to call the animator of your game object in this case the panel or the camera with something like:
public Animator animatorMyObject;
Once you set your variable you can either call it or fill it from the code within start or awake or drag the object to the inspector panel if you make it a public variable.
Once you do that you can access the properties of the animator in your case the boolean with an instruction like:
animatorMyObject.SetBool("Exact_Name_of_the_boolean_in_animator", false);
animatorMyObject.SetBool("Exact_Name_of_the_boolean_in_animator", true);
glad to help, don't forget to mark the answer as correct points are appreciated ;)
Answer by EGGamer · Sep 30, 2017 at 02:03 PM
IT WORKS! Thanks @jointothedarkside ! See how it looks: https://youtu.be/JUmQ8Dk_q_8 Thank you very much!
Answer by unity_G2yrNlWYdpJKuw · Sep 30, 2017 at 12:03 PM
I don't completely understand you, but try watching this video and I hope it will help you! https://www.youtube.com/watch?v=f5Eg3t3glWs