O'Reilly logo

Unity Android Game Development by Example Beginner's Guide by Thomas Finnegan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required