- Home /
Play an animation through script and then revert to default animation?
Hello, I started with Unity a few months ago and I would like to understand if I'm doing things the right way with animations. I'm using 2D characters with sprites, and for example if I need to animate a beam of a weapon, I usually attach a child gameobject with a separate controller to the main gameobject, being for example a enemy. As default animation a put a transparent sprite, then when the character shoots I send a animator.SetBool and make the transition. First of all, is it correct to use a transparent sprite when no animations have to be played, or there is a better way? Second, how can I automatically switch back to the default transparent animation after the "beam" one has been played? At the moment I'm doing it through script, with Time.delta time when I reach a certain amount of time in the Update, I send another SetBool, but I feel it's complicated and unefficient. Thanks.
Answer by Zankaster · Feb 28, 2014 at 11:55 AM
Found out by myself how to revert to base animation, instead of bool you have to use a trigger.