Journal 141 — Unity Project Development, 2.5D Shooter
Objective: To update the enemy weapon
In the previous article, I added a wave system for enemies and got them moving on a waypoint system. In this article, I will add a basic enemy weapon to fire randomly.
First, I will update the bullet projectile script so I can use it for the player projectiles and also the enemy. Both the enemy and player projectiles are destroyed after leaving the game area.
Then, I will add a new empty game object to the enemy prefab for where the enemy missiles can be instantiated, similar to how I set up the player. I will also add a function for the enemy missiles to instantiate and call the movement function in the Bullet script.
In the Enemy base script, I will get a reference to the WeaponFire script in order to instantiate the enemy missiles. I will use a timer to fire missiles randomly. Since I’m using a waypoint system to return the enemy fighters to the right side of the screen, I’m also restricting the missiles to only fire within the game screen.
Now, let’s check the results.
Thank you for your time!
The next article will be longer. I will go over several interrelated updates to add power ups to power up the player’s weapons, and also the hit triggers to destroy both an enemy and player, and also a restart option after the player is destroyed.