Time for action – adding an enemy ship
To make our enemy ships, we will need a script to turn our enemy ship into a prefab:
- The first thing we need to do is create a new script and call it
EnemyShip. This script will control the movement and shooting of the enemy ships.
- The script starts off with several variables. The first two define the speed with which the ship moves forward and how fast it turns.
public float moveSpeed = 8f;
public float turnSpeed = 0.5f;
- The next three variables are for controlling the shooting of the ship. First is the rate at which bullets are fired. It is followed by the range that the ship has to be within to fire at the player. Third is a holder for how long it has been since the last bullet was fired. This will work with ...