I'm having a bit of trouble when using an enemy spawn sprite to spawn multiple instances of the same enemy. As each one is spawned every few seconds, I want each one to behave independently. choosing its own direction and amount of time to wait. I've checked through many existing topics on this forum already and have attempted those solutions, but still can't get it quite right.
The code in question involves these Spawn sprites and these sEnemyFlyer sprites in the code below. The first small bit is the code for the spawner to spawn the sEnemyFlyer enemy. The larger bit below the black line is the AI that each sEnemyFlyer should adopt and use.
Here's what I would expect to happen:
1) As each Flyer is created from the spawned, it first checks the "On created > sEnemyFlyer" Event, then does all the actions in that event including settings its own instance variable for "AI" to 0.
2) When that instance of the Flyer enemy sets its AI to 0, it then trigger the next event once, choosing a direction, waiting a random amount of time, then switching to AI =1
3) After doing all the actions when AI = 1, it should switch back to AI = 0, resetting the animation and starting over.
The problem here is that none of the enemies created by the spawner behave correctly: they don't appear to inherit the "On created" actions, and only travel at 0 degrees at their Bullet.Speed value, ignoring the entire AI loop. The only case where this enemy almost works is when an sEnemyFlyer is already present on the layout at the start. In other words, the only one not spawned from the spawner sprite.
I would tend to think this is an issue of picking combined with the "For each" loop, but no matter how I configure it, I can't seem to get these enemies behaving properly and independently. If you know of any solutions, please share them. Thank you for taking the time to read my question!