Objective: Enable the enemies in my project to move in a new way.
So now that I have all the framework nearly completed, I want to focus on the enemies for this one. It’s nice that I have them moving in one direction from the top of the screen on the y-axis, but let’s spice this up a little bit and give these enemies some new flare to their movement.
So originally, in my enemy script, I passed in a Calculate Movement method with indicates how they spawn from the top and move downwards toward the bottom. Here is the initial code for that:

When the enemy spawns from the top of the game screen, I want to implement a way for the enemy to begin moving left and right. The approach I took to implement this was to create an “int” variable and use it as a random indicator at which type of movement the enemy will take.
The enemy will either move straight down, diagonally left, or diagonally right. I give the variable a “random.range” value in void start.