Objective: Create an enemy that fires a laser at player when the enemy gets behind the player.
Within the Enemy script, create a new enemy type, _enemyID of 4, that will attack the player from behind . Increasing _enemyID = Random.Range(0, 4) to _enemyID = Random.Range(0, 5) in void Start() creates this new enemy type 20% of the time. In void Update() modify the laser fire to allow an aimed shot, as shown below. After instantiating the enemy laser, the laser needs to point at the player. Since this is 2D game, transform.LookAt or Quternion.LookRotation collapse the collider and are…
Objective: Using Unity add a UI element that shows both the current and maximum laser power levels
Currently the game has two types of ammo lasers and missiles, so create UI text objects named Ammo_text and Missile_text. Anchor them in the upper right corner, as shown above, with font size of 20 and set color to white. Use SerializeField to assign these objects to the variables below.
Objective: Create an enemy that rams the player when it gets within range.
The Enemy script controls enemy behavior. The variables shown below will be used to control the enemy behavior to try to ram the player. The _enemyID is assigned using Random.Range(0, 4) and if it is 3 then will ram the player if in range, _playerDetectRange.
Objective: Add powerup allowing the player to fire two homing missiles that target the nearest enemy.
Adding homing missiles is a complex task, requiring a powerup for the player to get the missiles, visual effects for the missiles, code for the player to fire the missile and identify the enemy, and code for the missile move to and destroy the target once fired. The initial step is to create the missile.png file, using PowerPoint®. Drag this file into the Unity asset folder and the Texture Type set to Sprite (2D & UI).
Objective: Give some enemies a shield which blocks one hit.
Take the Enemy prefab and drag it into the scene, and set position to (X 0, Y 0, Z 0). Copy the Player’s Shield and paste as child of the Enemy. Change shield position to (X 0, Y 0, Z 0) and set the shield’s scale to 1.0 for X, Y, Z. Make sure the shield is inactive. Apply overrides to the Enemy prefab.
Objective: Allow thrusters to overheat if used too long, requiring a cooldown system before they can be used again.
Create an UI image for the afterburner indicator, naming it Thruster_Energy. Anchor it to the top left move it to just under the life indicator at roughly (x 100, y -90, z 0). Attach the Thruster_00000 sprite as the source image from GameDevHQ Filebase. Change its z rotation to 90 and set the height and width as shown below. Change the image type to filled, fill method vertical and fill origin top. …
Objective: Add a laser powerup that that recharges the laser allowing player to fire.
Create 2D sprites for laser powerup and animation using Power Point or other program. Drag these sprites into Unity Assets Laser_Powerup folder, select the sprites and set texture type to Sprite (2D & UI).
Objective: Add ammo system with audio warnings to laser shots.
Limiting the number of laser shots the player can take requires an ammo system in the Player script. This system is controlled by the private int _ammo =15 variable. Using Audacity, record an audio file for low ammo warning and another for the no ammo warning, saving in a Unity compatible mp3 format. Assign these files to the AudioClip variables _powerLowClip and _powerDepletedClip using the Unity inspector.