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
Asked
Active
Viewed 122 times
1 Answers
0
2 Issues here:
- 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. - 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 anonCreated
event for your enemies, setisGameStarted
to 1. Finally, add another condition to your level increment event that checks to make sureisGameStarted = 1.
Any time you are going to wipe all the enemies, make sure to setisGameStarted = 0
first to avoid triggering a level change.

Jeff Neet
- 734
- 1
- 8
- 22