Time for action – What's your malfunction?
One bug we'll notice playing around with this new enemy spawner code is that even after the match is over, the enemies keep moving toward us. There's no "pause" button being hit so this is normal behavior, but it's not what we want. Having them vanish wouldn't look quite right either, so let's just have them stop like the player does. To do this we'll have to start in our AwesomeGame
class.
We know the
ScoreObjective
function can tell us when the number of enemies reaches zero, so that's a good place to start. Let's add a bit of code toScoreObjective
:function ScoreObjective(PlayerReplicationInfo Scorer, Int Score) { local int i; EnemiesLeft--; super.ScoreObjective(Scorer, Score); if(EnemiesLeft == 0) { for(i=0; i<EnemySpawners.length; i++) EnemySpawners[i].FreezeEnemy(); } }
Now if
EnemiesLeft
is0
, it will iterate through theEnemySpawners
array and tell all of them to freeze their enemies.The next...