- Home /
Trying to Destroy Object when Wave starts
I am trying to destroy an object at the start of a specific wave. I currently have an on screen gui that keeps track of each wave and a spawn controller that tells the gui what wave it is with the var currentWave. I am using the gui script to destroy the object. This is the script.
 static var currentWave = 0; 
 
 function Update ()
 {
 
 guiText.text = "Wave : " + (currentWave + 1);
 
 if(currentWave = 4);{
  Destroy(gameObject.Find("Barrier1"));
     }
 }
I keep getting an error saying "Assets/Scripts/WaveManager.js(8,16): BCE0044: expecting ), found '='. " and Assets/Scripts/WaveManager.js(8,18): BCE0043: Unexpected token: 4.
What do I need to change if(currentWave = 4) to in order to make this work?
Answer by Mortennobel · Aug 27, 2011 at 06:17 PM
Note that = means assignment of value and == compares variables. In your case you need to use == to compare the values.
Another bug is that you should remove the semi-colon in the if statement
I new it had to be something trivial I was overlooking. $$anonymous$$any thanks.
Your answer
 
 
             Follow this Question
Related Questions
Pick up objects 2 Answers
Is a unity object really destroyed if its destructor was never called? 1 Answer
Clones of object wont disapear.. 1 Answer
how to save destroyed state of an object 1 Answer
Singleton Error with code 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                