UPDATE
Problem resolved - see comments below.
ZIP FILE OF GAME .c3p
https://drive.google.com/file/d/166Uiht-XNNaHucbyLIDLzuXLReWCF5Y5/view?usp=sharing
WHAT I'ME TRYING TO DO
In my Enemy Spawn System, the EnemySpawnArea objects are set to spawn an Enemy (one of three types randomly) when the animation for the EnemySpawnArea object reaches a certain frame.
At this point, the Enemy is spawned and the value of the global variable TotalActiveEnemies increases by 1.
NOTE: I know that I can track all the Enemies by putting them into a Family and tracking the system count value, but I would like to have a variable I can manipulate if I need to.
WHAT'S THE PROBLEM?
When you open the Layout 1 layout, you'll see that I have 8 EnemySpawnArea objects in the center of the arena where all the action will take place (surrounding the green square that is the Spaceship_Base object).
When the Wave starts, color-coded "sparkles" should emit from the spawn areas that are activated (this is controlled by a separate process and everything works fine there). I have confirmed that each spawn area will only spawn one Enemy type at a time so you should be able to confirm in the system menu in debug mode that there are X Enemies as you can see visually.
But when you check the global variable TotalActiveEnemies, it will not match the actual count of Enemies in the layout despite being calculated at the same time an Enemy is spawned - on the same action line!
REQUEST
Goes without saying - I need help to understand what's going on and what my oversight is so I can fix this (or if you have a quick-and-obvious-except-to-me solution!).
I will keep working on this, myself, until I figure it out or someone provides a viable solution.
Thank you for your time!