- Home /
Wait to Reload
if(Input.GetKeyDown ("r")){
    Reload();
 
}
function Reload(){
     if(Clips > 0){
     
     PlayReloadAudio();
     
     yield WaitForSeconds( ReloadTime );
     
         BulletsLeft = BulletsPerClip;
         
             Clips -= 1;
     }
}
Guys, how do I "lock" key r during the reload? :/
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by syclamoth · Nov 19, 2011 at 03:44 AM
Keep a boolean
 var reloading = false;
then in your function Reload-
 function Reload(){
     if(Clips > 0 && !reloading){
         reloading = true;
         PlayReloadAudio();
         yield WaitForSeconds( ReloadTime );
         BulletsLeft = BulletsPerClip;
         Clips -= 1;
         reloading = false;
     }
 
 }
Your answer
 
 
             Follow this Question
Related Questions
Change Automatic to Semi-Automatic 1 Answer
Function reload doesnt work 1 Answer
Shoot script help 1 Answer
SCRIPT NOT WORKING 2 Answers
shooting straight 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                