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?
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