- Home /
Question by
Carson365 · Dec 22, 2017 at 04:19 PM ·
animationcomponentanimationclipclip
Playing an animation
Hello! I have an object with an animation component, and the animation component has 2 different animations attached to it. I am wondering how to play either one of them through script. Thanks.
Comment
Answer by FadiLoutf · Dec 22, 2017 at 06:09 PM
Example :
First animation name attacked is : " animation1" , And the second "animation2"
GetComponent<Animation>().Play("animation1");
//OR
GetComponent<Animation>().Play("animation2");
Answer by Carson365 · Dec 22, 2017 at 06:39 PM
Hmm, it isn't working. Pretty much I have an animation that moves a panel down and an animation that moves that panel back up when the player presses Space. I tested it on another script with just Input.GetKeyDown and it still didn't work. The panel going down animation is working fine but the panel that goes back up isn't.
Your answer
![](https://koobas.hobune.stream/wayback/20220612145041im_/https://answers.unity.com/themes/thub/images/avi.jpg)