- Home /
Play animation only once?
So I'm still very new to animating in unity so far but I have an animation for a popup text so that it will rise onto the screen for a few seconds then go back under the UI, but this should only happen each time something is picked up. The closest I've gotten this to working is that the animation is constantly playing. The main error I keep getting is that there is no function name specified? This is the code that i'm using to play the animation when selected:
animator1.Play("popuptextanim");
Thanks!
cant you set loop property to false? animator1.play should only play the anim once.
Yeah whenever I turn it back off it plays once then doesn't do it again when I select an object?
Answer by JxWolfe · Mar 02, 2019 at 01:13 AM
change your system to use a animator rather than just animation. Second, set up a animation of your pop up in action, than of your pop up in an idle state. Lastly set up your animator to use a trigger, when activated, play pop up animation, after that switch back to idle. To activate the new animator, use the code Animator example.SetTrigger("Pop up");
Worked perfect and know that this will be super helpful in the future, thank you!