Enemy spawner
I created a rudimentary enemy spawner that uses arrow components to spawn cubes on their location. If my game used a variable amount of lanes, I could turn this code into a function that spawns a specified amount of components per lane used for gameplay. This is not necessary for the 4 lanes I will use in the demo.

I reused the sentry method to find the enemy actor’s current location, set it to a new distance relative to time and replace its current location with this value to move them downwards slowly every frame. Later, I can add the functionality for them to be destroyed when this value exceeds a certain number when they pass off the bottom of the camera.

I added my red material instance from when I was experimenting in chapter 3 to the enemies. This will be reused when I create the second enemy type that the player doesn’t want to hit to make them visually distinct.
Although I could have created the second enemy type as a separate actor with unique functionality when hit, I decided that making a variable that tracks if enemies are red and lowers score and lives based on this when hit would be more efficient (not yet implemented below).

Score addition
I learned how to utilise timers for functions that want to recursively call themself to avoid memory leaks. The timer function to give the player score calls itself once every 0.2 seconds to add one to the score; although larger values at slower intervals would be less performance intensive, adding score quickly will increase player satisfaction.

To test the timer cancelling functionality, I added a clear condition for the timer where it will stop adding score at a certain number. This is not used in the final project since 9999 is a near-unobtainable score, but it could be useful to set milestones where at certain score boundaries new enemy types appear.
