-1
\$\begingroup\$

I have four spawners in my scene that spawns four enemies. My problem is when I try to add game objects to the list it works but only for one spawner.

My code

if (Score.levelNum >=2 ){
  germtype.Remove(pupplegerm);
  germtype.Add(blackgerm);
  germtype.Add(blackgerm);
}
else if(Score.levelNum >=3 ){
  germtype.Remove(bluegerm);
  germtype.Add(greengerm);
  germtype.Add(greengerm);
}

I want to add a new enemy / germ each time the player moves up a level. I have green germ and black germ stored in a variable.

\$\endgroup\$
1
\$\begingroup\$

Remove the else from the other conditions, as only the first condition triggers. That is because something greater than or equal to three is also greater than two.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.