x


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?

more ▼

asked Aug 27 '11 at 05:58 PM

Ajaxx84 gravatar image

Ajaxx84
35 8 11 13

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Aug 27 '11 at 06:17 PM

Mortennobel gravatar image

Mortennobel
1.8k 10 15 34

I new it had to be something trivial I was overlooking. Many thanks.

Aug 27 '11 at 06:23 PM Ajaxx84
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3815
x1123
x785
x114
x35

asked: Aug 27 '11 at 05:58 PM

Seen: 593 times

Last Updated: Aug 27 '11 at 06:27 PM