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:

  1. 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.
  2. 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;
  3. 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 ...

Get Unity Android Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.