- Home /
c# play animation on key down
How would i play an annimation using the e key?
Answer by rednax20 · Aug 11, 2013 at 03:49 PM
 function Update(){
     if(Input.GetKeyDown("e")){
         animation.Play("animation");
     }
 }
You could have easily found this information on google, or the unity manuel.
http://docs.unity3d.com/Documentation/ScriptReference/Input.GetKeyDown.html
Seriously? it is pretty much the same for C#... Learn to use the Scripting Reference
as someone new and learning code yes seriously, i have used the Scripting Reference before, learn to ask rather than suggest.
$$anonymous$$y reaction is because this is te C# version...
 void Update(){
     if(Input.Get$$anonymous$$eyDown("e")){
        animation.Play("animation");
     }
 }
 
So except for the update function declaration (which you should already have), it is exactly the same.
Oh, sorry about the java, I assumed that they were the same.
Your answer
 
 
             Follow this Question
Related Questions
Can the animation editor create local rotational data? 3 Answers
Adding animation clips via script 2 Answers
how to make a animation play only if you press a certain key? 8 Answers
Movement animation 1 Answer
how would i slow this animation 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                