0

I have an issue with finishing a level using global variable when I make a global variable for enemy count is = 0 then add 1 to level variable, but when I start the game and destroy all enemies the global variable keep adding 1 to levels Continuously and all levels are unlocking along with this variable. Now I want it should add only one level

tariq khan
  • 21
  • 1
  • 2
  • 8

1 Answers1

0

2 Issues here:

  1. Use add trigger once while true as a condition to the event that checks if count = 0. Without this, every tick that condition is true (before another enemy spawns) level will be incremented.
  2. You don't wan't to start checking until the first enemy spawns. One possible solution is to add a global variable called isGameStarted initialized to 0. Then using an onCreated event for your enemies, set isGameStarted to 1. Finally, add another condition to your level increment event that checks to make sure isGameStarted = 1. Any time you are going to wipe all the enemies, make sure to set isGameStarted = 0 first to avoid triggering a level change.
Jeff Neet
  • 734
  • 1
  • 8
  • 22