Day 9: Creating enemy behavior
Objective: Create a program for the enemy that spawns the enemy at the top of the screen at a random position on the X axis when it reaches the bottom of the screen.
To start, we need to make another script named enemy for the enemy behavior. Then, in the script we need to create a speed variable to control how fast the enemy can move. Since we may want to change this variable later make sure to use the serialized field function.
Next, we need to create the movement of the enemy. For this example I want to move it down at 4 meters per second.
Lastly, we want to create a respawn system so that if the enemy reaches the bottom we respawn it at a random interval on the X axis at the top of the screen. So, this will use an if statement that looks like this: