Play animation once then play idle loop animation?
So i am making a game and i have to where if i press '1' a game object will appear that is attached to the player. and i want this game object to play a "appear" animation before going into its idle animation until it is called back by pressing '1' again. and then if i were to press '1' again it would do the same thing. How do i get it to play the animation once then go to idle every time? I have no clue, anything would help. Here is my script (java script)
pragma strict
var show : boolean = false; var target : GameObject; var anim : Animator;
function Start() {
}
function Update () { if(Input.GetKeyDown(KeyCode.Alpha1)) { if(show == false) { target.SetActive(true); show = true; anim.SetTrigger("nanoAppear"); } else { target.SetActive(false); show = false; anim.SetBool("nanoIdle",true); } } }
Answer by Jeff-Kesselman · Jun 04, 2017 at 11:55 PM
THis is a perfect use of mechanim.
You should read about how it works.
Your answer
![](https://koobas.hobune.stream/wayback/20220612123513im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Walking animation javascript? 2 Answers
Idle , Move and Attack animations 0 Answers
BCE0020 error with animation 1 Answer
BCE0043 and BCE0044 errors, expecting ), found '.' and unexpected token ) 0 Answers
Help with variables 1 Answer