- Home /
Script keeps functioning when disabled
Hey everyone. I have a shooting script for a tank, and when there are no more enemies present, the script disables. Though it shows the the script is disabled, it continues to fire rounds. Does anyone know why this is?
Here is the script:
 var bullet : Transform;
 
 var canshoot : boolean;
 
 var Tank : Transform;
 
 InvokeRepeating("RPS", 1, 5);
 function RPS () {
 if(canshoot == true){
 audio.Play();
 Instantiate(bullet, transform.position, transform.rotation);
 Tank.animation.Play();
 }
 }
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by robertbu · Dec 15, 2013 at 05:10 PM
InvokeRepeating() is not disabled when a game object is disabled. Not sure how you want to handle this. Maybe you can add this to your script:
 function OnDisable () {
     canshoot = false;
 }
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                