What I am trying to do is I am making a tower defense game and I want my spawn script to stop after my counter reaches a number. This is what I have so far.
//creat time and set to 3 second
public float interval = 3.0f;
float timeleft = 0.0f;
// Human game object to spawn
public GameObject Human = null;
public int counter = 0;
// Update is called once per frame
void Update () {
//time left untill next spawn
timeleft -=Time.deltaTime;
if (timeleft <= 0.0f)
{
counter ++;
//spawn human
GameObject enemy = (GameObject)Instantiate(Human, transform.position, Quaternion.AngleAxis(-90, Vector3.left));
//reset time
timeleft = interval;
if(counter == 3)
{
}
I just cant figure out how to make the script stop after it the counter reaches 3. please help.