- Home /
 
               Question by 
               MinecraftUnity · Jun 02, 2012 at 06:44 PM · 
                javascripttoggleruntapsprint  
              
 
              Double tap to run
How do I make it so if a player double taps UP ARROW to run. Here's what I got following a tutorial (this is only a portion of the whole thing):
 if(Character)
 {
     // toggle between walk and run with <left shift> R
     if(Input.GetKey(KeyCode.LeftShift) && Input.GetKeyDown(KeyCode.R))
     {
         if(running == true){
             running = false;
             if(walking == true) Character.animation.CrossFade("walk");
         } 
         else{
             running = true;
             if(walking == true) Character.animation.CrossFade("run");
         }
     }
 }
               Comment
              
 
               
              Answer by The1nk · Jun 11, 2012 at 10:18 PM
You probably want to record the time when the player presses the Up Arrow, and check it every time the up arrow is pressed. If the difference is less than a threshold, maybe 1 second, then toggle a variable (`running = true;`) and continue.
Of course, you'd also want to reset the variable (`running = false;`) after the up arrow is released to prime it for the next movement.
Hope this helps!
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                